Download presentation
Presentation is loading. Please wait.
1
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write) Receive (or Read) –Both could be connectionless Disconnect (or Close)
2
2 Berkeley Sockets ‘Sockets’ are one of the 2 major Unix network programming application programming interfaces. The other is the System V Transport Layer Interface (TLI). Sockets are biased towards Unix and C. Good references are Doug Comer’s Vol III –both of them!
3
3 Unix File I/O Unix treats a file as a ‘stream of bytes’ API calls: open, creat, read, write, lseek, close All operate on file descriptors File descriptors are int’s, but represent a more complex structure
4
4 Socket I/O Transport layer also provides ‘stream of bytes’ type service to the upper layers API calls: –socket: Initialize data structure –bind: set addresses –listen: specify a queue –accept: wait for connection –connect: initiate a connection –read, write, recv, send: transfer data –close, shutdown: terminate connection –recvfrom, sendto: datagrams
5
5 Local Remote IP Port Local Remote IP Port
6
6 Overview -- connection Server Client socket()bind()listen() accept() read()connect()socket()bind()write() server blocks Optional(!!)
7
7 Overview -- connectionless Server Client socket()bind() recvfrom() sendto() socket()bind()recvfrom() server blocks
8
8 Socket Paradigm Setup is ‘client/server’ because someone has to start the conversation BUT, communication is bidirectional (either end can read or write) Sockets (in Unix) are multiprotocol: –TCP/IP, UNIX, XNS {address families}
9
9 Server Types Iterative –Receive request, process it, go to next on queue –Best in connection-less environment Concurrent –Receive request, fork process, reset socket –Best when extended interaction is needed
10
10 Socket ‘Details’ If you don’t want to block on a read, look at the select system call. You’ll need the following includes: –#include Program examples are available on net.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.