#include "socket.h" #include #include #include #include int socket_tcp(int block) { int s; s = socket(AF_INET,SOCK_STREAM,0); if (s == -1) return -1; if(block) return s; if (fcntl(s,F_SETFL,fcntl(s,F_GETFL,0) | O_NONBLOCK) == -1) { close(s); return -1; } return s; }