Appendix A. Socket Function Quick Reference

Socket-Specific Functions

socketpair(2)

#include <sys/types.h>
#include <sys/socket.h>

int socketpair(int domain, int type, int protocol, int sv[2]);

socket(2)

#include <sys/types.h>
#include <sys/socket.h>

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

bind(2)

#include <sys/types.h>
#include <sys/socket.h>

int bind(int sockfd, struct sockaddr *my_addr, int addrlen);

connect(2)

#include <sys/types.h>
#include <sys/socket.h>

int connect(int sockfd, struct sockaddr *serv_addr, int addrlen);

listen(2)

#include <sys/socket.h>

int listen(int s, int backlog);

accept(2)

#include <sys/types.h>
#include <sys/socket.h>

int accept(int s, struct sockaddr *addr, int *addrlen);

Socket Addressing

getsockname(2)

 #include ...

Get Linux Socket Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.