VC++网络编程,怎么处理socket接收到的数据
答案:1 悬赏:50 手机版
解决时间 2021-12-18 02:45
- 提问者网友:过期关系
- 2021-12-17 04:03
VC++网络编程,怎么处理socket接收到的数据
最佳答案
- 五星知识达人网友:不正经的草莓
- 2021-12-17 05:38
VC++ 用Socket持续接收数据的程序举例如下:
while(1) { //client receiving code
if ((numbytes = recv(sockfd, buf, MAXDATASIZE, 0)) == -1)
perror("recv");
}
buf[numbytes] = '\0';
printf("numbytes is %d\n", numbytes);
printf("client: received '%s'\n", buf);
}
以下是输出:
numbytes is 0
client: received '12345'
numbytes is 0
client: received '6'
numbytes is 0
client: received ''
numbytes is 0
while(1) { //client receiving code
if ((numbytes = recv(sockfd, buf, MAXDATASIZE, 0)) == -1)
perror("recv");
}
buf[numbytes] = '\0';
printf("numbytes is %d\n", numbytes);
printf("client: received '%s'\n", buf);
}
以下是输出:
numbytes is 0
client: received '12345'
numbytes is 0
client: received '6'
numbytes is 0
client: received ''
numbytes is 0
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯