Julia Ljunbjörk and Anita Mugenyi
What is a socket? Like a house Between the layers
Socket programming Client –server Two ways
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)
process TCP with buffers, variables socket host or server process TCP with buffers, variables socket host or server Internet controlled by app developer
Socket programming with TCP Reliable, byte stream-oriented Three-way handshake Three sockets Streams
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
Socket programming with UDP No streams No connection Datagram socket Individual packets
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
Thank you for your time!