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

資源簡(jiǎn)介

壓縮包內(nèi)包含客戶(hù)端imclient.c 服務(wù)端imserver.c 以及makefile,測(cè)試在64位centos機(jī)器下運(yùn)行,需要安裝mysql數(shù)據(jù)。程序流程,客戶(hù)端通過(guò)讀取圖片數(shù)據(jù)然后通過(guò)socket將圖片數(shù)據(jù)發(fā)送給服務(wù)端,服務(wù)端接收數(shù)據(jù)后,插入數(shù)據(jù)庫(kù)。注意;數(shù)據(jù)庫(kù)字段位blob類(lèi)型,UTF8編碼格式。

資源截圖

代碼片段和文件信息

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

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

#include?
#include?

int?PtTcpSnd(int?sockfd?char?*buffer?int?length)
{
??int??len;
??int??totalcnt;?????
??totalcnt?=?0;
??
??printf(“Now?Send?Socket[%d]...“sockfd);
??while(totalcnt???{
????len?=?write(sockfd?buffer?+?totalcnt?length?-?totalcnt);
????printf(“Send?Socket?len[%d]“l(fā)en);
????if?(len?????{
??????if?(errno?==?EINTR)?
??????{
????????len?=?0;
????????break;
??????}
??????else
????????return(-1);
????}
????else?if?(len?==?0)
??????break;

????totalcnt?=?totalcnt?+?len;
??}

???return(totalcnt);
}


int?main()
{
int?cfd;
???
struct?sockaddr_in?s_add;
unsigned?short?portnum=12306;?
printf(“Hellowelcome?to?client?!\r\n“);

cfd?=?socket(AF_INET?SOCK_STREAM?0);
if(-1?==?cfd)
{
????printf(“socket?fail?!?\r\n“);
????return?-1;
}
printf(“socket?ok?!\r\n“);

bzero(&s_addsizeof(struct?sockaddr_in));
s_add.sin_family=AF_INET;
s_add.sin_addr.s_addr=?inet_addr(“127.0.0.1“);
s_add.sin_port=htons(portnum);


if(-1?==?connect(cfd(struct?sockaddr?*)(&s_add)?sizeof(struct?sockaddr)))
{
????printf(“connect?fail?!\r\n“);
????return?-1;
}
printf(“connect?ok?!\r\n“);

FILE?*fp?=?fopen(“qr.jpg“?“rb“);
??
??if?(fp?==?NULL)?
??{
??????fprintf(stderr?“cannot?open?image?file\n“);????
??????exit(1);
??}
??????
??fseek(fp?0?SEEK_END);
??
??if?(ferror(fp))?{
??????
??????fprintf(stderr?“fseek()?failed\n“);
??????int?r?=?fclose(fp);

??????if?(r?==?EOF)?{
??????????fprintf(stderr?“cannot?close?file?handler\n“);??????????
??????}????
??????
??????exit(1);
??}??
??
??int?flen?=?ftell(fp);
??
??if?(flen?==?-1)?{
??????
??????perror(“error?occurred“);
??????int?r?=?fclose(fp);

??????if?(r?==?EOF)?{
??????????fprintf(stderr?“cannot?close?file?handler\n“);
??????}
??????
??????exit(1);??????
??}
??
??fseek(fp?0?SEEK_SET);
??
??if?(ferror(fp))?{
??????
??????fprintf(stderr?“fseek()?failed\n“);
??????int?r?=?fclose(fp);

??????if?(r?==?EOF)?{
??????????fprintf(stderr?“cannot?close?file?handler\n“);
??????}????
??????
??????exit(1);
??}

??char?data[flen+1];

??int?size?=?fread(data?1?flen?fp);
??
??if?(ferror(fp))?{
??????
??????fprintf(stderr?“fread()?failed\n“);
??????int?r?=?fclose(fp);

??????if?(r?==?EOF)?{
??????????fprintf(stderr?“cannot?close?file?handler\n“);
??????}
??????
??????exit(1);??????
??}
??
??int?r?=?fclose(fp);

??if?(r?==?EOF)?{
??????fprintf(stderr?“cannot?close?file?handler\n“);
??}?
??printf(“%d\n?[%#x]\n“?size?data);
if?(PtTcpSnd(cfd?data?size)?printf(“sending?on?stream?socket“);???
close(cfd);???
exit(0);???
}??

close(cfd);
return?0;
}


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

?????文件???????2905??2015-05-22?09:07??imserver.c

?????文件????????348??2015-05-22?09:07??makefile

?????文件???????2957??2015-05-22?09:07??imclient.c

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

?????????????????6210????????????????????3


評(píng)論

共有 條評(píng)論

相關(guān)資源