1 / 10

Socket Programming with TCP and UDP

Socket Programming with TCP and UDP. Julia Ljunbjörk and Anita Mugenyi. What is a socket ?. Like a house Between the layers. Socket programming. Client –server Two ways. Socket programming.

tuyet
Télécharger la présentation

Socket Programming with TCP and UDP

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. SocketProgramming with TCP and UDP Julia Ljunbjörk and Anita Mugenyi

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

  3. Socketprogramming • Client –server • Twoways

  4. Socketprogramming • A client reads a line from its standard input (keyboard) and sends the lineoutitssocket to the server • The server reads a line from itssocket • The server converts the line to uppercase • The server sends the modifiedlineoutitssocket to the client • The client reads the modifiedline from itssocket and prints the line on its standard output(monitor)

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

  6. Socketprogramming with TCP • Reliable, byte stream-oriented • Three-way handshake • Three sockets • Streams

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

  8. Socketprogramming with UDP • No streams • No connection • Datagram socket • Individual packets

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

  10. Thank you for your time!

More Related