Presentation is loading. Please wait.

Presentation is loading. Please wait.

Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers.

Similar presentations


Presentation on theme: "Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers."— Presentation transcript:

1 Julia Ljunbjörk and Anita Mugenyi

2 What is a socket? Like a house Between the layers

3 Socket programming Client –server Two ways

4 Socket programming 1. A client reads a line from its standard input (keyboard) and sends the line out its socket to the server 2. The server reads a line from its socket 3. The server converts the line to uppercase 4. The server sends the modified line out its socket to the client 5. The client reads the modified line from its socket and prints the line on its standard output(monitor)

5 process TCP with buffers, variables socket host or server process TCP with buffers, variables socket host or server Internet controlled by app developer

6 Socket programming with TCP Reliable, byte stream-oriented Three-way handshake Three sockets Streams

7 wait for incoming connection request connectionSocket = welcomeSocket.accept() create socket, port= x, for incoming request: welcomeSocket = ServerSocket() create socket, connect to hostid, port= x clientSocket = Socket() close connectionSocket read reply from clientSocket close clientSocket Server (running on hostid ) Client send request using clientSocket read request from connectionSocket write reply to connectionSocket TCP connection setup

8 Socket programming with UDP No streams No connection Datagram socket Individual packets

9 Server (running on hostid ) close clientSocket read datagram from clientSocket create socket, clientSocket = DatagramSocket() Client Create datagram with server IP and port=x; send datagram via clientSocket create socket, port= x. serverSocket = DatagramSocket() read datagram from serverSocket write reply to serverSocket specifying client address, port number

10 Thank you for your time!


Download ppt "Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers."

Similar presentations


Ads by Google