Download presentation
Presentation is loading. Please wait.
1
Sockets Basics Conectionless Protocol
2
Today IPC Sockets Basic functions Handed code Q & A
3
Interprocess Communication Mechanism to allow processes to communicate and to synchronize their actions Within the same system or different systems Best provided by messaging systems (no shared variables)
4
IPC types Pipes FIFOs Streams and messages Message queues, semaphores and shared memory (system V) Sockets and TLI
5
Sockets Communication among processes in the same system (pipes) and different systems Characteristics –Unique address –Domain dependent Types –Stream –Sequenced –Datagram –Raw Connectionless Vs connection oriented
6
Connectionless Oriented Socket Bind recvfrom sendto Blocks until data received from a client Process request Server Socket Bind sendto recvfrom Client
7
Basic functions socket (int family, int type, int protocol) : defines the socket –Address family: UNIX, internet, Xerox NS, IMP –Type: stream, datagram, raw, sequenced –Protocol argument: specify protocol (tcp, udp, icmp, etc) –Returns a socket file descriptor
8
Basic functions… cont Bind (int sockfd, struct sockaddr *myaddr, int addrlen) : assigns a name to an unnamed socket (“this is my adddress and any messages received for this address are to be given to me”) –sockfd: socket file descriptor –struct sockaddr: protocol specific address (family, port, address - netid) –addrlen: size of the structure –returns error if so
9
Basic functions… cont sendto (int sockfd, char *buff, int nbytes, int flags, struct sockaddr *to, int addrlen) : send message recvfrom (int sockfd, char *buff, int nbytes, int flags, struct sockaddr *to, int addrlen) : receive message –buff: message –nbytes: length of the message
10
Handed code Init_socket send_packet receive_packet get_addr_byname
11
Questions and Answers
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.