Sockets
Sockets
A Socket is a :-
• It is an API
user user
kern kern
el el
Socket Socket
Underlying Underlying
communicati communicati
on Protocols on Protocols
Communication
s network
Port numbers
Well known ports:-
• 0-1024
Registered ports
• 1024-49151
Dynamic ports
• 49152-65535
System calls for connection
oriented protocol [TCP/IP]
Server side system calls :-
• Socket
• Bind
• Listen
• Accept
• Read
• Write
System calls for connection
oriented protocol [TCP/IP]
Client side system calls :-
• Socket
• Connect
• Write
• Read
Server
TCP client-server
socket()
bind()
Client
listen()
accept()
socket()
data write()
read()
write() data
read()
close()
close()
Networks: TCP/IP 6
Socket Calls
System calls for connection less
protocol [UDP/IP]
Server side system calls :-
• Socket
• Bind
• Recvfrom
• Sendto
System calls for connection less
protocol [UDP/IP]
Client side system calls :-
• Socket
• Bind
• Sendto
• recvfrom
UDP Socket Calls
Server
socket()
Client
socket()
bind()
sendto() data
recvfrom()
close()
close()
Networks: UDP/IP
Socket Calls
Socket programming
# include <sys/socket.h>
struct in_addr {
in_addr_t s_addr ;
};