prithul
prithul

Reputation: 347

Using UDP to let clients know server's existance, is it possible?

I am very new to network programming, so this might be a no brainer. What I was wondering is, I know TCP requires the client to know the IP of the server. But since UDP is connectionless server, is it still required? I mean can I make my server broadcast it's IP address on a specific port ( not necessary in the same LAN , also over internet) and make the clients listen to that port for any incoming requests and find get the IP of the server once a request is received ?

Upvotes: 0

Views: 85

Answers (2)

Jovi DSilva
Jovi DSilva

Reputation: 226

Look into using ARP/RARP if that gives you what you need. Coming to your question

Mind you both TCP and UDP require IP addresses binding the ip address to a port is called a socket and there can be TCP and UDP with the same port no.

You can do this according to what you said but then the server needs to know the client addresses

  1. Create a connection from server to client
  2. Send IP address of server to client
  3. Client send data using just received Server IP

to work around this you can use the broadcast address of the network and have the clients listen to it, just check what your broadcast address is.

What you are trying to do is similar to a DHCP server.

Upvotes: 0

Robban64
Robban64

Reputation: 63

You can try to send packages on specific port over the LAN. But for the Internet no.

Upvotes: 1

Related Questions