Types of Internet Sockets
● Stream Sockets (SOCK_STREAM)– Connection oriented
– Rely on TCP to provide reliable two-way connected
communication
● Datagram Sockets (SOCK_DGRAM)
– Rely on UDP
– Connection is unreliable
socket() -- Get the file descriptor
● int socket(int domain, int type, int protocol);– domain should be set to PF_INET
– type can be SOCK_STREAM or SOCK_DGRAM
– set protocol to 0 to have socket choose the correct
protocol based on type
– socket() returns a socket descriptor for use in later
system calls or -1 on error
int sockfd;
sockfd = socket (PF_INET, SOCK_STREAM, 0);
No comments:
Post a Comment