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

  • 大小: 102KB
    文件類(lèi)型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-12
  • 語(yǔ)言: C/C++
  • 標(biāo)簽: C語(yǔ)言??

資源簡(jiǎn)介

基于C語(yǔ)言的多人聊天室,C/S結(jié)構(gòu),可在在linux系統(tǒng)下運(yùn)行,附有report和源碼,使用mysql數(shù)據(jù)庫(kù),當(dāng)有用戶進(jìn)入聊天室時(shí),會(huì)通知所有人

資源截圖

代碼片段和文件信息

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

#define?BUFFER_SIZE?1024
#define?FILE_NAME_MAX_SIZE?1024
#define?HELLO_WORLD_SERVER_PORT???6666

?struct?sockaddr_in?clientaddr;
???pid_t?pid;
???int?clientfdsendbytesrecvbytes;
???struct?hostent?*host;
???char?*buf*buf_r;
???MYSQL?*conn;
???MYSQL_RES?*res;
???MYSQL_ROW?row;
???char?*i;
???char?*userid;
???char?*userpwd;
???char?sql[1024];
???char?*Name;
???
???
???ssize_t?r_write(int?fd?void?*buf?size_t?size)?{
???char?*bufp;
???size_t?bytestowrite;
???ssize_t?byteswritten;
???size_t?totalbytes;

???for?(bufp?=?buf?bytestowrite?=?size?totalbytes?=?0;
????????bytestowrite?>?0;
????????bufp?+=?byteswritten?bytestowrite?-=?byteswritten)?{
??????byteswritten?=?write(fd?bufp?bytestowrite);
??????if?((byteswritten)?==?-1?&&?(errno?!=?EINTR))
?????????return?-1;
??????if?(byteswritten?==?-1)
?????????byteswritten?=?0;
??????totalbytes?+=?byteswritten;
???}
???return?totalbytes;
}

sendfile(void?*ppid_t?id)
{

????int?client_socket?=?socket(AF_INETSOCK_STREAM0);
????client_socket?=?*(int?*)p;


????char?file_name[FILE_NAME_MAX_SIZE+1];
????bzero(file_name?FILE_NAME_MAX_SIZE+1);
????printf(“Please?Input?File?Name?On?Server:\t“);
????scanf(“%s“?file_name);
????
????char?buffer[BUFFER_SIZE];
????bzero(bufferBUFFER_SIZE);
????strncpy(buffer?file_name?strlen(file_name)>BUFFER_SIZE?BUFFER_SIZE:strlen(file_name));
????//鍚戞湇鍔″櫒鍙戦€乥uffer涓殑鏁版嵁
????send(client_socketbufferBUFFER_SIZE0);

????int?fp?=?open(file_name?(O_WRONLY|O_CREAT|O_EXCL)(S_IRUSR?|?S_IWUSR));
????if(?fp?//????FILE?*?fp?=?fopen(file_name“w“);
?//???if(NULL?==?fp?)
????{
????????printf(“File:\t%s?Can?Not?Open?To?Write\n“?file_name);
????????exit(1);
????}
????
????//浠庢湇鍔″櫒鎺ユ敹鏁版嵁鍒癰uffer涓?????bzero(bufferBUFFER_SIZE);
????ssize_t?length?=?0;
????length?=?recv(client_socketbufferBUFFER_SIZE0);
????
?????????
????????if(length?????????{
????????????printf(“Recieve?Data?From?Server??Failed!\n“);
????????????exit(1);
????????}
????????int?write_length?=?r_write(fp?bufferlength);
?????????
??//??????int?write_length?=?fwrite(buffersizeof(char)lengthfp);
????????if?(write_length????????{
????????????printf(“File:\t%s?Write?Failed\n“?file_name);
????????????exit(1);
????????}
????????memset(buffer‘\0‘BUFFER_SIZE);
????????bzero(bufferBUFFER_SIZE);????
????
????printf(“Recieve?File:\t?%s?From?Server?Finished\n“file_name);
????close(fp);
????
?//???fclose(fp);
????recv(client_socketbufferBUFFER_SIZE0);
???//?close(client_socket);
????return?0;
}

???void?sigOut(int?sigNum)
{

strcpy(bufName);
strcat(buf“?“);
memset(buf_r0100);

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

?????文件?????226816??2009-11-04?22:57??project?report.doc

?????文件???????8289??2009-11-04?22:51??server5.c

?????文件???????6465??2009-11-05?00:15??client5.c

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

???????????????241570????????????????????3


評(píng)論

共有 條評(píng)論

相關(guān)資源