⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 network.h

📁 即时通信程序(类似于QQ,MSN) 用C写的
💻 H
字号:
/*     *   This program is free software; you can redistribute it and/or modify *   it under the terms of the GNU General Public License as published by *   the Free Software Foundation; either version 2 of the License, or *   (at your option) any later version. * *   This program is distributed in the hope that it will be useful, *   but WITHOUT ANY WARRANTY; without even the implied warranty of *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *   GNU General Public License for more details. * *   You should have received a copy of the GNU General Public License *   along with this program; if not, write to the Free Software *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * *********************************************************************************/ #ifndef _NETWORK#define _NETWORK#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#ifndef _WIN32#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <netdb.h> #else#include <winsock.h>#endif    //structure de paquet// - un destinataire (numero du socket)// - un tag (type de paquet)// - une valeur// - suivant dans la liste (facultatif)struct _paquet{ short destinataire; char tag[20]; char valeur[255]; struct _paquet *next;};struct _client{ short socket; char ip[16]; struct _client *next;};class network{ public :  network(int);			//constructeur de la classe  ~network();			//destructeur de la classe  int demarre_serveur();	//lance l'interface reseau  int demarre_client(char*);	//lance l'interface reseau en version client  int update_input();		//met a jour le buffer d'entree  int update_output();		//met a jour le buffer de sortie  int envoi(int, char*, char*);	//cree un paquet et l'ajoute au buffer de sortie  struct _paquet *get_paquets(); //renvoie la liste des paquets arriv閟  void ferme_client(int);	//ferme un client  void set_debug(short);	//acive/d閟active le mode debug  void dump_liste_in();		//affiche le buffer d'entr閑  void dump_liste_out();	//affiche le buffer de sortie  char * get_ip(short);    //renvoie l'ip d'un client  void broadcast_msg(char *, char *); //message pour tous  int remove_id;      //id d'un client qui s'est deconnect

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -