Socket UDP
H. Fauconnier 1-1
M2-Internet Java
UDP
H. Fauconnier M2-Internet Java 2
M2-Internet Java 3
Socket programming with UDP
UDP: no “connection” between
client and server
no handshaking
sender explicitly attaches
IP address and port of
destination to each segment
OS attaches IP address and
port of sending socket to
each segment
Server can extract IP
address, port of sender
from received segment
application viewpoint
UDP provides unreliable transfer
of groups of bytes (“datagrams”)
between client and server
Note: the official terminology
for a UDP packet is “datagram”.
In this class, we instead use “UDP
segment”.
H. Fauconnier
Running example
Client:
User types line of text
Client program sends line to server
Server:
Server receives line of text
Capitalizes all the letters
Sends modified line to client
Client:
Receives line of text
Displays
M2-Internet Java 4
H. Fauconnier
M2-Internet Java 5
Client/server socket interaction: UDP
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
H. Fauconnier
1 / 59 100%
La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans linterface ou les textes ? Ou savez-vous comment améliorer linterface utilisateur de StudyLib ? Nhésitez pas à envoyer vos suggestions. Cest très important pour nous !