server端在linux上,client端在winCE上,通过tcp socket传输byte{]

来源:百度知道 编辑:UC知道 时间:2024/05/19 12:52:06
如题
为什么server只能收16byte以下的东西,如果收更长的byte[],server端只能收一次数据,然后就跳error,说socket已经断开
有没有人遇到过类似的情况,好奇怪啊~~~~
回复一楼:我没有设置过,应该就是默认的了吧?

我刚刚给其他的朋友写的socket程序发给你

服务器:
include <string.h>
#include <stdio.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>

#define LINE 2048

pthread_mutex_t work = PTHREAD_MUTEX_INITIALIZER;

struct sockaddr_in tcpsock, udpsock;

void *handle_tcp(void *arg)
{
int tcpfd = *((int *)arg);
int tcpcon;
int n;
char *suc = "success";
socklen_t len = 0;
struct sockaddr_in tcpcli;
listen(tcpfd, 20);
char str[INET_ADDRSTRLEN];
char buf[LINE];

while(1)
{
len = sizeof(tcpcli);
tcpcon = accept(tcpfd, (struct sockaddr*)&tcpcli, &len);
pthread_mutex_lock(&work);
printf("receive from %s at port %d\n",
inet_ntop(PF_INET, &tcpcli.sin_addr, str, sizeof(str)),
ntohs(tcpcli.sin_por