1.LINUX socket 在connect的时候发生 Operation now in progress 错误
unsigned long ul = 1;
ioctl( nSocket, FIONBIO, &ul ); //设置为非阻塞模式
放到connect()后面.
查找这类问题就打印strerror(errno)来查
2.accept失败
conn_fd=accept(listen_fd,(struct sockaddr*)&serv_addr,NULL))
原因第三个参数应该是serv_addr长度的指针
改为:
int len = sizeof(struct sockaddr);
if(-1==(conn_fd=accept(listen_fd,(struct sockaddr*)&serv_addr,&len)))即可