3.socket APIs Slide
3.socket APIs Slide
Nội dung
• Basics of socket
• Sockets API
BASICS OF SOCKET
Socket Pair
• four-tuple that defines the two endpoints of
the connection
– the local IP address
– local port
– foreign IP address
– foreign port
• The 2 values that identify each endpoint, an IP
address and a port number, are often called a
socket.
TCP Port Numbers and Concurrent
Servers (1)
TCP Port Numbers and Concurrent
Servers (2)
TCP Port Numbers and Concurrent
Servers (3)
TCP Port Numbers and Concurrent
Servers (4)
Buffer Sizes and Limitations
• Maximum size of an IPv4 datagram: 65,538 bytes
• MTU (Maximum transmission unit)
• Fragmentation when the size of the datagrram
exceeds the link MTU.
– DF bit (don’t fragment)
• MSS (maximum segment size): that announces to
the peer TCP the maximum amount of TCP data
that the peer can send per segment.
• MSS = MTU – fixed size of headers of IP and TCP
TCP output
UDP output
Protocol Usage by Common
Internet Applications
SOCKETS API
Socket Address Structures
• IPv4 Socket Address Structure: sockaddr_in
(including <netinet/in.h>)
#include <arpa/inet.h>
int inet_aton(const char *strptr, struct
in_addr *addrptr);
Returns: 1 if string was valid, 0 on error