当前位置: 技术问答>linux和unix
*************(简单问题!!:()帮我看看这段socket连接哪里错了???急死了(没多少分了抱歉)~~~~!!!!!!!11
来源: 互联网 发布时间:2015-03-07
本文导语: 我是想让客户端去连服务器, 但是每次都报broken pipe 如果把accept 那段注释掉,下面往这个端口发数据时就没反应,怎么办阿!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //open data connection int datafd; struct sockaddr_in datacli; struct in_addr data...
我是想让客户端去连服务器,
但是每次都报broken pipe
如果把accept 那段注释掉,下面往这个端口发数据时就没反应,怎么办阿!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//open data connection
int datafd;
struct sockaddr_in datacli;
struct in_addr datain;
struct hostent *datasn;
char sendln[1024], myftp[4048];
bzero(&datacli, sizeof(datacli));
//bzero(myftp, sizeof(myftp));
//bzero(sendln, sizeof(sendln));
datacli.sin_family = AF_INET;
datacli.sin_port = htons(2562); // a*256 +b:port
char selfip[]="172.16.197.17";
inet_pton(AF_INET, selfip, &datacli.sin_addr); // self ip
datain.s_addr = inet_addr(selfip);
datasn = gethostbyaddr((char *)&datain, 4, AF_INET);
printf("datasn=%xn",datasn);
printf("before connect");
if((datafd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))