Socket function list.

xiaoxiao2021-03-06  42

TCP Socket: ************************************************************* ********* # include #include #include #include #include #include

Server:

int socket (int domain, int type, int protocol); int bind (int s, const struct sockaddr * name, int namelen); int accept (int s, struct sockaddr * addr, socklen_t * addrlen); int listen (int s , int backlog); ssize_t read (int fildes, void * buf, size_t nbyte); ssize_t write (int fildes, const void * buf, size_t nbyte); int getsockname (int s, struct sockaddr * name, socklen_t * namelen); int getpeername (int s, struct sockaddr * name, socklen_t * namelen); char * inet_ntoa (const struct in_addr in); uint16_t htons (uint16_t hostshort); int close (int fildes); in_addr_t inet_addr (const char * cp);

Client:

INT Connect (int S, const strunt sockaddr * name, int namelen); PID_T FORK (VOID);

*********************************************************** ****** UDP Socket:

#include #include #include

INT Socket (int Domain, int type, int protocol); SSIZE_T Recvfrom (int S, Void * Buf, Size_t Len, Int Flags, Struct SockAddr * from, INT * FROMLEN)

SSIZE_T Sendto (int S, Const Void * MSG, SIZE_T LEN, INT FLAGS, CONST STRUCKADDR * TO, INT TOLEN);

INT Bind (int S, Const struct sockaddr * name, int namelen);

转载请注明原文地址:https://www.9cbs.com/read-59680.html

New Post(0)