资源简介

C语言基于socket多人聊天(包含注册登录),有注册和登录模块,验证通过才可以发信息。可实现多人同时在线发信息,或者一对一发信息

资源截图

代码片段和文件信息

/*
 *title: client.c
 *start_time: Mar.18 2011
 *end_time:  Apr.8 2011
 */

#include “i.h“

#define START_PORT 8089

struct sockaddr_in my_addr;
int my_id;

int my_log();/* declare funtion*/

/* */
int i_send_msg()
{
int id;
struct msg the_msg;
char end = ‘@‘;

printf(“input recver id:“);
scanf(“%d“ &id);
getchar();
printf(“\ninput content:“);
i_input(the_msg.content);

char flag = ‘y‘;

if (1)
{
the_msg.flag = 1;
the_msg.id_from = my_id;
the_msg.id_to = id;

i_sendto(sockfd &the_msg sizeof(struct msg) 0
(struct sockaddr*)&server sizeof(struct sockaddr));

i_saveto_chat(&the_msg); /* save to history */

printf(“send to id:%d success.\n“ my_id);
return(0);
}
else
return(1);

return(0);
}

int reply()
{
return(0);
}
int send_file()
{
return(

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4768  2013-08-08 16:20  i.h

     文件       6083  2013-08-08 16:20  server.c

     文件       8113  2013-08-08 16:20  client.c

----------- ---------  ---------- -----  ----

                18964                    3


评论

共有 条评论