julia ljunbjörk and anita mugenyi. what is a socket? like a house between the layers
TRANSCRIPT
![Page 1: Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers](https://reader036.vdocuments.mx/reader036/viewer/2022083004/56649d9c5503460f94a84d70/html5/thumbnails/1.jpg)
Socket Programming with TCP and UDP
Julia Ljunbjörk and Anita Mugenyi
![Page 2: Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers](https://reader036.vdocuments.mx/reader036/viewer/2022083004/56649d9c5503460f94a84d70/html5/thumbnails/2.jpg)
What is a socket?Like a houseBetween the layers
![Page 3: Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers](https://reader036.vdocuments.mx/reader036/viewer/2022083004/56649d9c5503460f94a84d70/html5/thumbnails/3.jpg)
Socket programmingClient –serverTwo ways
![Page 4: Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers](https://reader036.vdocuments.mx/reader036/viewer/2022083004/56649d9c5503460f94a84d70/html5/thumbnails/4.jpg)
Socket programming1. 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 socket3. The server converts the line to uppercase4. The server sends the modified line out its
socket to the client5. The client reads the modified line from its
socket and prints the line on its standard output(monitor)
![Page 5: Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers](https://reader036.vdocuments.mx/reader036/viewer/2022083004/56649d9c5503460f94a84d70/html5/thumbnails/5.jpg)
process
TCP withbuffers,variables
socket
host orserver
process
TCP withbuffers,variables
socket
host orserver
Internet
controlled byapp developer
![Page 6: Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers](https://reader036.vdocuments.mx/reader036/viewer/2022083004/56649d9c5503460f94a84d70/html5/thumbnails/6.jpg)
Socket programming with TCPReliable, byte stream-oriented Three-way handshakeThree socketsStreams
![Page 7: Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers](https://reader036.vdocuments.mx/reader036/viewer/2022083004/56649d9c5503460f94a84d70/html5/thumbnails/7.jpg)
wait for incomingconnection requestconnectionSocket =welcomeSocket.accept()
create socket,port=x, forincoming request:welcomeSocket =
ServerSocket()
create socket,connect to hostid, port=xclientSocket =
Socket()
closeconnectionSocket
read reply fromclientSocket
closeclientSocket
Server (running on hostid) Client
send request usingclientSocketread request from
connectionSocket
write reply toconnectionSocket
TCP connection setup
![Page 8: Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers](https://reader036.vdocuments.mx/reader036/viewer/2022083004/56649d9c5503460f94a84d70/html5/thumbnails/8.jpg)
Socket programming with UDPNo streamsNo connectionDatagram socketIndividual packets
![Page 9: Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers](https://reader036.vdocuments.mx/reader036/viewer/2022083004/56649d9c5503460f94a84d70/html5/thumbnails/9.jpg)
Server (running on hostid)
closeclientSocket
read datagram fromclientSocket
create socket,clientSocket = DatagramSocket()
Client
Create datagram with server IP andport=x; send datagram via clientSocket
create socket,port= x.serverSocket = DatagramSocket()
read datagram fromserverSocket
write reply toserverSocketspecifying client address,port number
![Page 10: Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers](https://reader036.vdocuments.mx/reader036/viewer/2022083004/56649d9c5503460f94a84d70/html5/thumbnails/10.jpg)
Thank you for your time!