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

資源簡介

在unbantu下用c語言實現的命令聊天室、可通過客戶端上傳和下載文件,還可實現單聊功能

資源截圖

代碼片段和文件信息

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

?typedef?struct{
int?type;
int?fd;
int?fp;
int?Mask;
char?name[20];
char?filename[30];
char?buf[1000];
}Masg*Pm;

Pm?P;

?void?*task(void?*arg)
?{
?int?s?=?*(int?*)arg;
?

?struct?json_object?*obj*type*data*name*filename*sure;
????
?
//?write(P->fdbufstrlen(buf));
?
??while(1)
??{
???char?buf[1024]={};
???????char?filedata[10]={};
???int?res?=recv(sbufsizeof(buf)0);
??if(res<=0)
??break;??
?//?strcpy(buf“{\“type\“:1}“);
????obj?=?json_tokener_parse(buf);
type?=?json_object_object_get(obj“type“);
//printf(“type:%p\n“type);
data?=?json_object_object_get(obj“data“);
//printf(“data:%p\n“data);
name?=?json_object_object_get(obj“name“);
filename?=?json_object_object_get(obj“filename“);
//printf(“filename:%p\n“filename);
????sure?=?json_object_object_get(obj“sure“);
//printf(“sure:%p\n“sure);
??????????//?printf(“buf?****?=%s\n“buf);

// printf(“%s\n“json_object_to_json_string(obj));

if(json_object_get_int(type)==1)
{
????
???//?printf(“%s\n“json_object_to_json_string(obj));
printf(“群聊消息:%s\n“json_object_get_string(data));

}
else?if(json_object_get_int(type)==2)
{

if(sure!=NULL)
{
????????if(strcmp(json_object_get_string(sure)“nofile“)==0)
??{
?printf(“沒有該文件\n“);
?continue;
??}?
??
??if(strcmp(json_object_get_string(sure)“finish“)==0)
?{
?printf(“下載完成\n“);
?close(P->fd);
?continue;
?}?
}

if(filename!=NULL)
{
if(strcmp(json_object_get_string(filename)P->filename)==0)??//返回文件名并創建
???{
???????P->fd?=open(P->filenameO_WRONLY|O_CREAT|O_TRUNC0666);
????????????????????????if(P->fd==-1)
??????????????????????{
??????????perror(“sendfile“);
??????????continue;
???????????????????????}?
?
???}
}
?
?if(data!=NULL)
?{
??
????{

???????write(P->fdjson_object_get_string(data)strlen(json_object_get_string(data)));

?????}???
?}
???
}
else?if(json_object_get_int(type)==3)
{

//printf(“%s\n“json_object_to_json_string(obj));

if(sure!=NULL)
{
??????if(strcmp(json_object_get_string(sure)“fail“)==0)
????{
???printf(“上傳失敗\n“);
???continue;
????}

?????if(strcmp(json_object_get_string(sure)“ready“)==0)
?{
?printf(“準備傳輸\n“);
?} ?
?
}
?????json_object_object_del(obj“sure“);?
?????json_object_object_del(obj“filename“);?
??
while((res=read(P->fpfiledatasizeof(filedata)-1))>0)
{
//printf(“%s**************%ld\n“filedatasizeof(fi

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????18704??2018-10-29?19:31??TCPchat\cilent1\cilent1

?????文件???????9560??2018-10-29?18:55??TCPchat\cilent1\cilent1.c

?????文件????????290??2018-10-29?20:08??TCPchat\cilent1\file.txt

?????文件????????206??2018-10-27?15:18??TCPchat\cilent1\test.txt

?????文件????????290??2018-10-26?11:21??TCPchat\server\file.txt

?????文件??????18864??2018-10-29?19:44??TCPchat\server\server

?????文件???????8654??2018-10-29?19:43??TCPchat\server\server.c

?????文件????????206??2018-10-29?20:09??TCPchat\server\test.txt

?????文件??????21650??2018-10-30?18:29??TCPchat\設計文檔.docx

?????目錄??????????0??2018-10-29?20:08??TCPchat\cilent1

?????目錄??????????0??2018-10-29?20:09??TCPchat\server

?????目錄??????????0??2018-10-30?18:29??TCPchat

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

????????????????78424????????????????????12


評論

共有 條評論