91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 24KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-08
  • 語言: C/C++
  • 標(biāo)簽: MFC??

資源簡(jiǎn)介

MFC 實(shí)現(xiàn)聊天功能

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include
#include
#include?
#include?
#include?
#include?

#define?SERVPORT?2345?????//端口號(hào)
#define?MAXDATASIZE?1024??//傳輸結(jié)構(gòu)體數(shù)據(jù)域最大字節(jié)

typedef?struct
{

??int?flag;
??char?name[10];
??//char?sex;
??char?password[20];
}REGMESSAGE;

typedef?struct?msgNode
{
char?attrstr[56];
char?msgstr[56];
struct?msgNode?*next;
}msgNode*msgList;

typedef?struct?dNode{
int?type;
int?src_client_fd;
int?des_client_fd;
char?buf[MAXDATASIZE];
}dataNode*dataPtr;

typedef?struct?QNode
{
dataNode?data;
struct?QNode?*next;
}QNode*QueuePtr;

typedef?struct
{
QueuePtr?front;//隊(duì)頭指針
QueuePtr?rear;//隊(duì)尾指針
}linkQueue;

/*?定義全局變量*/
//客戶端信息
int?sockfd;
int?myfd;
char?myname[10];
//標(biāo)志
int?insetflag?=?0;//發(fā)送參數(shù)設(shè)置
int?wrlockflag?=?0;//隊(duì)列寫鎖
//時(shí)間變量
time_t?timep;
//所有窗口指針
WINDOW?*inputWin*inputMsgWin*inputDesWin*inputTypeWin*inputCallWin;?
WINDOW?*msgWin*msgCntWin;
WINDOW?*userListWin*userListCntWin;?
msgList?mlist;//消息鏈表指針
linkQueue?sendQueuerecvQueue;//接受?發(fā)送隊(duì)列

/*?初始化隊(duì)列?*/
void?InitQueue(linkQueue?*Q)
{
Q->front?=?(QueuePtr)malloc(sizeof(QNode));
Q->rear?=?Q->front;
Q->front->next?=?NULL;
//Q.rear->next?=?NULL;
}
/*?隊(duì)列?數(shù)據(jù)入列?*/
void?EnQueue(linkQueue?*QdataNode?e)
{
QueuePtr?p;
p?=?(QueuePtr)malloc(sizeof(QNode));
p->data.type?=?e.type;
p->data.src_client_fd?=?e.src_client_fd;
p->data.des_client_fd?=?e.des_client_fd;
memcpy(p->data.bufe.bufMAXDATASIZE);
p->next?=?NULL;
Q->rear->next?=?p;
Q->rear?=?p;
}

/*?隊(duì)列?數(shù)據(jù)出列?*/
void?DeQueue(linkQueue?*QdataNode?*e)
{
QueuePtr?p;
p?=?Q->front->next;
e->type?=?p->data.type;
e->src_client_fd?=?p->data.src_client_fd;
e->des_client_fd?=?p->data.des_client_fd;
memcpy(e->bufp->data.bufMAXDATASIZE);
Q->front->next?=?p->next;
if(Q->rear?==?p)
Q->rear=Q->front;
free(p);
}

/*?判斷隊(duì)列是否為空?*/
int?EmpQueue(linkQueue?Q)
{
if(Q.front?==?Q.rear)
return?1;
else
return?0;
}

/*?初始化消息內(nèi)容無頭結(jié)點(diǎn)循環(huán)鏈表,長(zhǎng)度為8結(jié)點(diǎn)?*/
void?msgList_init(void)//
{
msgNode?*p*s;
mlist?=?NULL;
int?i;
for(i?=?0;?i? {
p?=?(msgNode?*)malloc(sizeof(msgNode));
strcpy(p->attrstr““);
strcpy(p->msgstr““);
p->next?=?NULL;
if(i?==?0)
{
mlist?=?p;
s?=?mlist;
}
else
{
s->next?=?p;
s?=?s->next;
}
}
s->next?=?mlist;
}

/*?更新消息鏈表,mlist指向最先收到的消息?*/
void?msgList_updata(char*?attrchar?*msg)
{
strcpy(mlist->attrstrattr);
strcpy(mlist->msgstrmsg);
mlist?=?mlist->next;
}

/*?獲取時(shí)間函數(shù)?*/
void?gettime(char?*str)
{
struct?tm?*p;
time(&timep);
p?=?gmtime(&timep);
sprintf(str“%02d:%02d:%02d“p->tm_hour+8p->tm_minp->tm_sec);
}
/*?修改提示信息?*/
void?setcall(int?num)
{
char?callstr[58];
wclear(inputCallWin);
switch(num)
{
case?1: //輸入消息
strcpy(callstr“提示:請(qǐng)輸入消息,按Enter鍵發(fā)送!Ctrl+C更改發(fā)送參數(shù)!“);
break;
case?2: //輸入消息?錯(cuò)誤信息
strcpy(callstr“錯(cuò)誤:消息為空請(qǐng)重新輸入!Ctrl+C更改發(fā)送參數(shù)!“)

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件??????15893??2010-09-15?09:56??M\client

?????文件??????12617??2010-09-15?09:55??M\client.c

?????文件??????12617??2010-09-15?09:55??M\client.c~

?????文件??????10157??2010-09-15?09:56??M\server

?????文件???????7904??2010-09-15?08:08??M\server.c

?????文件???????7900??2010-09-15?08:08??M\server.c~

?????文件??????????4??2010-09-14?16:43??M\test.c~

?????目錄??????????0??2010-09-15?13:19??M

-----------?---------??----------?-----??----

????????????????67092????????????????????8


評(píng)論

共有 條評(píng)論