当前位置: 技术问答>linux和unix
TCP 套接字 连接拒绝错误 实在想不到什么问题
来源: 互联网 发布时间:2017-04-05
本文导语: 本帖最后由 usc_su 于 2013-03-26 05:10:33 编辑 如题,请大家给点意见,下面是client部分代码: int GeneralTCP(){ int socketId1,socketId2; int length1,length2; char *s1,*s2; struct sockaddr_in remote_addr1,remote_addr2; printf("The General has TCP ...
int GeneralTCP(){
int socketId1,socketId2;
int length1,length2;
char *s1,*s2;
struct sockaddr_in remote_addr1,remote_addr2;
printf("The General has TCP port 4229 and IP address 127.0.0.1n");
//set addresses of captain1 and captain2
remote_addr1.sin_family=AF_INET;
remote_addr2.sin_family=AF_INET;
remote_addr1.sin_addr.s_addr=inet_addr("127.0.0.1");
remote_addr2.sin_addr.s_addr=inet_addr("127.0.0.1");
remote_addr1.sin_port=htons(21629);
remote_addr2.sin_port=htons(21729);
//open sockets for captain1 and captain2
if((socketId1=socket(PF_INET,SOCK_STREAM,0))