Presentation is loading. Please wait.

Presentation is loading. Please wait.

Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system.

Similar presentations


Presentation on theme: "Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system."— Presentation transcript:

1 Vassil Roussev vassil@cs.uno.edu

2 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system controlled by application developer controlled by operating system controlled by application developer process Host (end system) Internet process Host (end system) TCP/IP stack TCP/IP stack Network access is managed by the OS.  OS provides a socket API to allow network communication socket

3 3 Socket Programming using TCP service process write read bytes process read write socket Application Viewpoint TCP provides reliable, in-order transfer of a stream of bytes between two end points (processes). Internet Same interface as other stream I/O (files, pipes, etc.). Pair of pipes abstraction

4 4 read write TCP communication is based on the client/server concept. write read bytes Welcoming socket TCP Client 3-way handshake Connection socket Client socket TCP Server Server is started first & waits for connection requests. Client initiates connection via 3-way handshake. Once established, connection is completely symmetrical.

5 5 A port number is a 16-bit number that uniquely identifies a network process on a host. Server binds to a desired port number (welcoming socket). Client must know port number to reach server. PortPID 0000--- 0021 0022 0025 0080 0631 … … … … Most standard servicesstandard services have a default port: File Transfer  Secure Shell  Simple Mail Transfer  World Wide Web  Print Service  Client sockets use any available port >1023. ftpd sshd smtpd httpd cupsd bind()

6 6 Network Addressing for Sockets A  B socket connection: DNS Host name: cook.cs.uno.edu Mnemonic, logical ID IP address: 137.30.120.32 Unique, routable ID Local process IDs hostAhostB

7 7 The CapsLock example service converts strings sent by clients to upper case. Protocol: Client: Gets a line of text from the user via the system’s standard input Client: Sends the line to the server over the network Server: Receives the line from the client Server: Converts it to uppercase Server: Sends back the uppercase line Client: Receives uppercase line from server Client: Displays it via the system’s standard output

8 8 Stream View of the Problem (Client) Flash review Input stream: –Sequence of bytes going into a process –E.g., from keyboard, file, socket Output stream: –Sequence of bytes coming out of a process –E.g., to display, file, socket Client process Std input Client socket inFromServer outToServer Standard output

9 9 Client/Server Socket Interaction: TCP Wait for incoming connection request connectionSocket = welcomeSocket.accept() Create socket for incoming requests, bind to port 6789 welcomeSocket = ServerSocket(6789, 5) Create socket, connect to 137.30.120.32, port = 6789 clientSocket = new Socket(137.30.120.32, 6789) Close connectionSocket Read reply from clientSocket Close clientSocket Server (running on cook.cs.uno.edu ) Client Send request using clientSocket Read request from connectionSocket Write reply to connectionSocket TCP connection setup

10 process send recv process recv send socket Internet  10 Socket Programming using UDP service Application Viewpoint UDP provides unreliable transfer of groups of bytes—datagrams—between two end points (processes). Not a stream interface Each datagram addressed explicitly (no connection). No delivery guarantee!

11 11 Client/Server Socket Interaction: UDP close clientSocket Server (running on cook.cs.uno.edu) read reply from clientSocket Create socket for sending requests: clientSocket = DatagramSocket() Client Create, address ( 137.30.120.40,9876), send datagram request using clientSocket Create socket for incoming request: serverSocket = DatagramSocket(9876) read request from serverSocket write reply to serverSocket specifying client host address, port number

12 12 TCP/UDP CapsLock Example Demos gitlab: vroussev/csci4311-f14/code


Download ppt "Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system."

Similar presentations


Ads by Google