Elementary Socket Calls
int socket (int family, int type, int protocol);
- open a socket (specifying the type of protocol)
-
int bind (int sockfd, struct sockaddr *myaddr, int addrlen);
- assigns a name (local address) to the socket
-
int connect (int sockfd, struct sockaddr *servaddr, int addrlen);
- client establishes connection with a server
-
int listen (int sockfd, int backlog);
- server indicates it is willing to receive connections
-
int send (int sockfd, char * buff, int nbytes, int flags);
- send message to other end of connection (TCP)
-
int sendto (int sockfd, char *buff, int bytes, int flags, struct sockaddr *to, int addrlen);
- send message to the specified receiver