Reputation: 1288
I have a server application (that simply starts a Server Socket) and a client application, let's suppose that I have several server application instances started on the same local network, is there a way for my client application to list all the running servers on the local network (maybe by some kind of name or id that I can define ?) ? Thank you
Upvotes: 0
Views: 501
Reputation: 595711
This is commonly solved by using either
a UDP subnet broadcast, where each server instance opens a listening UDP socket on a given port, and then replies to packets received on that port. Each reply is sent back to the sender it was received from, and can contain whatever identification data you want. The client can then broadcast a packet on that port, and gather up any replies it receives from servers that are connected to the same subnet.
any number of available network service discovery protocols, such as SSDP.
Upvotes: 2
Reputation: 6390
Use nmap and zmap if you are on linux.
To see open ports on your machine:
Windows: use CMD with admin rights
netstat -a -b
-a
Displays all connections and listening ports
Powershell:
-Id (Get-NetTCPConnection -LocalPort portNumber).OwningProcess
Upvotes: 1