Presentation is loading. Please wait.

Presentation is loading. Please wait.

Berkeley Socket Abstraction

Similar presentations


Presentation on theme: "Berkeley Socket Abstraction"— Presentation transcript:

1 Berkeley Socket Abstraction
Tom Skoczlas

2 History Created at UC Berkeley for use on UNIX
Provides an API for which to “abstract” TCP/IP communication “adopted” by Microsoft and renamed Winsock

3 Client-Server Model In software, it’s all client-server.
Application Layer Protocol describes the way client and server programs communicate

4 TCP vs UDP sockets TCP Sockets – Connection-oriented.
Idea of a “stream” UDP Sockets- Connection-less. One transmittion per send operation

5 Stateful vs Stateless Servers
Stateful – A server that keeps an active record of the communication. Example - Telnet Stateless – A server that keeps no record of the communication Example- Web (in general terms)

6 Client Algorithm (TCP)
Find IP and port of server Allocate a Socket Specify an unused port Communicate with the Server Close Connection

7 Client Functions (TCP)
socket() connect() send() recv() closesocket()

8 Server Algorithm (TCP)
Create a socket and bind it to a port. Place the socket in passive mode. Accept the incoming connection. Repeatedly receive a request, formulate and send back a response. When finished, close the connection and return to “acceptive” state.

9 Server Functions (TCP)
socket() bind() listen() accept() recv() send() closesocket()

10 UDP differences Client – can “skip” the connect() call.
In this case the sendto() function is used, and the endpoint must be specified each time Server – server is always receiving, since there is no “connection” No call to listen() or accept()

11 Concurrent vs Iterative Servers
Iterative: Block on I/O operations Concurrent: Allow multiple I/O operations at once Possible through: Multiple Threads Multiple Processes Software Polling

12 Winsock differences Winsock requires the use of the Winsock dynamically-linked library. Requires use of WSAstartup() and WSAcleanup to initialize and uninitialize the dll

13 Questions? Good reference – Internetworking with TCP/IP, VOL. 3: Client-Server Programming and Applications Comer & Stevens


Download ppt "Berkeley Socket Abstraction"

Similar presentations


Ads by Google