AutoDiscovery client and server on the same machine?

Is there a way to use the AutoDiscovery class when I’m running the client and the server on the same machine? The socket reports that it cannot bind a second time to the same port - which makes sense, but it’s a significant limitation.

You could use a virtual machine, those have a virtual network device with it’s own IP/ports.

Thanks for the suggestion, but that’s overkill.

Just do the auto discovery on it’s own port and leave your existing port for your actual protocol…

The goal is to be able to use AutoDiscovery to discover services that are running on the same machine as the code looking for them. As it stands, it looks like the AutoDiscovery class can’t do this.

Well, you could check for open ports, but anything above 1024 is fair game to be used by any program… But I doubt you will find any programming language that will let you run two services on the same port (because the operating systems don’t allow it)…

Are you looking for services that you are writing, or just services in general?

It’s a service I’m writing. Again: I don’t need multiple, duplicate data ports via TCP, I need to figure out how to use AutoDiscovery (or some other UDP-based technique) to advertise a service on the same machine that might be looking for it.

Based on my understanding of the AutoDiscovery class (which is just from reading the documentation)…

So your service binds to port X
You would bind AutoDiscovery to port X+1
You use the EasyUDPSocket to communication with the AutoDiscovery server
Your client, now knows that the service is running on the computer (whether local or remote) and connects on port X

It also looks like you can use AutoDiscovery and EasyUDPSocket to do the communications as well, so you can also just use that for a complete package (but it is UDP, so you’re probably better off using a TCPSocket and just have the two ports open)…

As soon as I wrote that previous sentence, it got me thinking… You should be able to bind something on UDP and something on TCP on the same port (I might be wrong on this though, but something that you can look up)

https://stackoverflow.com/questions/6437383/can-tcp-and-udp-sockets-use-the-same-port

Yes, you can… Whether Xojo lets you or not is another story…

Thanks for all your effort, but you are misunderstanding the question.

I’m not…

  • you want to broadcast that a service is available (AutoDiscovery, UDP, port X)
  • you want your client to connect to that service (Custom protocol/whatever, TCP, port X)

This is doable…

Clients do not bind to a socket, so you can run client and server on the same computer