資源簡介
C語言基于socket多人聊天(包含注冊登錄),有注冊和登錄模塊,驗證通過才可以發信息??蓪崿F多人同時在線發信息,或者一對一發信息
代碼片段和文件信息
/*
?*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
- 上一篇:簡單語言編譯器(含語法語義分析部分)
- 下一篇:背包問題C++用棧解決
評論
共有 條評論