#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <signal.h>
#define CLIENT_LOGIN 100
#define CLIENT_CHAT 200
#define CLIENT_QUIT 300
#define SERVER_CHAT 400
#define SERVER_QUIT 500
struct node
{
char name[20];
struct sockaddr_in client_addr;
struct node *next;
};
struct message
{
long type;
char name[20];
char mtext[512];
};
struct node *create_list(void);
void insert_list(struct node *, char *, struct sockaddr_in *);
void delete_list(struct node *, char *);
void recv_message(int , struct node *);
void send_message(int , struct sockaddr_in *, pid_t );
void client_login(int , struct node *, struct message *, struct sockaddr_in *);
void client_chat(int , struct node *, struct message *);
void client_quit(int , struct node *, struct message *);
void server_chat(int , struct node *, struct message *);
void server_quit(int , struct node *, struct message *);
评论7