首页 > 代码库 > socket

socket

pid_t forkvoid);返回值: 若成功调用一次则返回两个值,子进程返回0,父进程返回子进程ID;否则,出错返回-1

int socketpair(int d, int type, int protocol, int sv[2]);建立一对匿名的已经连接的套接字

int ret = socketpair( PF_UNIX, SOCK_STREAM, 0, sig_pipefd );

int socket(int domain, int type, int protocol);

int setsockopt(int sockfd, int level, int optname,const void *optval, socklen_t optlen);//SOL_SOCKET http://man.cx/setsockopt

address.sin_port = htons( port );

int bind(int sockfd, const struct sockaddr *addr,socklen_t addrlen);

int listen(int sockfd, int backlog);