Hi All, Thanks for your support. I am connecting two Photons, one been a TCP Server and other the Client. I noticed sometimes the TCP Server IP changes, and i have to change in the IP Address in the Client Firmware Code. Is there a way for the Client to Know who is the server and determine its IP address so I dont have to code it?
You could use a published/subscribed event via the Particle cloud. The server could publish it’s IP address at startup or periodically and the client could subscribe to that event.
Or you could assign a static IP address to your server in your router and in your firmware.
Thanks bko, i wanted to implement a solution where i dont have to depend on an Internet connection / cloud. I was thinking maybe try to discover all the devices in the network and start asking one by one if is the server and when i found the server i could get its IP address. Any ideas if this is possible? thanks
You can have devices operate on TCP when they know about each other. For discovery, but you might be able to utilize UDP mulitcast for this? There are several clients in other languages, but you should be able to create the udp multicast server and client from the examples.
As @cermak pointed out, UDP multicast can work well.
You can port scan from the client to the server depending on your network. In the client, get your own IP address and assuming that you are on a class C subnet (good assumption for a normal router) you just use the top three bytes of your IP address and vary the lower byte from 1 to 255 trying to connect to your server’s port.
This can attract unwanted attention in a managed IT environment since you are doing what some malware does in looking at all hosts for an open port.
Thanks Cermark, I am trying to build a very robust system that is able to work connected to the cloud and not connected. What it leave me a little nervous about UDP is that according to the example for the UDP multicast you shared with I me, i still need to code a fix IP and Port to multicast, What happens if these are being used by other device? Is there a way to know using coding in the firmware in the photon to test first if the IP and Port are been used by other device?
Thanks Bko, as you mention this may not be a good practice for network managers…