1 / 10

Generic Transport Service Primitives

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). Berkeley Sockets.

ilana
Download Presentation

Generic Transport Service Primitives

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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. 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. 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. 1.2.3.4 23 2.3.4.5 2000 “Big Picture” “Server” “Client” User Space Process User Space Process Program Program sd sd OS Space IP Port OS Space IP Port L 2.3.4.5 2000 L R 1.2.3.4 23 R duplicated Socket Socket

  5. 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

  6. socket() bind() listen() read() accept() socket() bind() connect() write() Overview -- connection Server server blocks Client Optional(!!)

  7. socket() bind() sendto() socket() bind() sendto() recvfrom() Overview -- connectionless Server server blocks recvfrom() Client

  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. 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. 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 <sys/types.h> • #include <sys/socket.h> • Program examples are available on net.

More Related