G
G
Georgy Pugachev2019-11-18 14:07:09
Computer networks
Georgy Pugachev, 2019-11-18 14:07:09

How to write a UDP server that works without Bind?

Wrote a client and a server to work with UDP. One sends, the other receives, everything is OK here.
But if I run a second server (on the same PC) and want the client to send messages to both of them at the same time (this is a broadcaster), then the second server application swears that it is impossible to bind to the same address.
How to make datagrams come to all N running servers? Abandon Bind?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Alexandrov, 2019-11-18
@gvpugachev

You have never broadcast. You have unicast.
You need broadcast to broadcast to your entire subnet.
Another option is multicast, unlike broadcast, the network will eat less.
Well, you can immediately make a notch that broadcast packets can be dropped by routers / routers, etc.
PS I read your comment. As Armenian Radio noted, this does not break the concept. Bypass it in a different way if you really need it.
1) Relatively speaking, you make a fixed port on SIDE_A, listen to the broadcast on it.
2) On SIDE_B, at startup, broadcast a packet to this fixed port, telling the server on which port it listens for packets.
3) PARTY_A catches this packet and starts broadcasting on the port, similarly listens from all other PARTIES

A
Armenian Radio, 2019-11-18
@gbg

No way. This breaks the concept of sockets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question