摘要:
fprintf(stdout,"%s",buffer);这会在屏幕打印出buffer.但是,当使用while(1){accept(...);rec = recv(...) ;fprintf(stdout,"%d",rec) ;}会没有输出~~why???这个时候,fprintf在什么地方输出呢?找到原因了:stdout是行缓冲的,所以遇到\n才会输出,如果没有,就会一直等待~~所以上面的fprintf改为:fprintf(stdout,"%d\n",rec) ;即可! 阅读全文
摘要:
int accept(int socket, struct sockaddr *address, socklen_t *address_len);int bind(int socket, const struct sockaddr *address, socklen_t address_len);int connect(int socket, const struct sockaddr *address, socklen_t address_len);int getpeername(int socket, struct sockaddr *address, socklen_t *address 阅读全文