Difference between UDP Server / UDP Client
Asked Answered
N

3

5

I'm trying to work with the UDP protocol, and I don't understand the difference between a UDP Server and a UDP Client. Don't they do the same thing ?

Nolitta answered 17/12, 2017 at 18:46 Comment(1)
A UDP server is always listening. A UDP client is only listening after sending a message, for a response. At least in most cases. Yes they are similar but logically they are different. I think the same goes for any communication protocol, not just UDP. Some are just easier to implement I guess.Lucielucien
E
5

The UDP server:

  • Runs first (to open a listen port)
  • Opens a specific port
  • Typically can accept multiple client connections

The UDP client:

  • Runs second (assuming the server is already running)
  • Indicates a specific target port
  • Randomly (usually) choose a source port that the server will reply to
  • Typically single-threaded and handles only one connection to the UDP server

In fact, it's not that much different from TCP, except there is no three-way handshake nor any flow-control and congestion-control.

Endothelioma answered 4/9, 2018 at 1:12 Comment(1)
UDP is a connectionless protocol by definition, so your reference to a UDP server "accepting multiple client connections" and a UDP client "handles only one connection to the UDP server" is incorrect. UDP works by sending datagram packets from a specific address:port to another address:port. Naturally, the receiver ("server") needs to exist (be listening) before a transmitter ("client") sends packets and it actually wants to receive them, but there is no connection estrablishment that takes place.Burbot
H
3

It actually depends from what point you look.

From point of server/client architecture it is definitely different. You can refer to other answers.

From socket programming point, it is quite same. Since UDP is connection-less, both server and client would use same sendto and recvfrom methods. There is no such socket API that is unique for server or client only(talking about UDP). So I would prefer to call sides peers or sender/receiver instead of server/client.

Homager answered 25/6, 2019 at 6:38 Comment(0)
Z
0

To quote from Wikipedia's entry for Client-server model:

The server component provides a function or service to one or many clients, which initiate requests for such services.

Putting this into my own words: the difference between a server and a client is a practical one with notions like centralization and roles. Take the difference between a server at a restaurant and a client at the server's table. Depending on things like the restaurant, a client may also be the server like at a buffet where you get food for your family or friends. Either way, the entity providing the service at the time, can be considered the server and the entity receiving the service is conceptualized as the client.

A client-server model isn't the only model either but rather is considered a "sub-category of distributed peer-to-peer systems".

Hope this helps!

Zosema answered 22/12, 2017 at 20:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.