Avatar of razza_b
razza_b
 asked on

TCPIP Connection status

Hi

Looking for some professional advice and possibly some code samples, I'm developing a solution for TCP Clients/TCP Listeners(no direct communication between then, only talking to other listeners and clients.)

This is basically a heartbeat detection to see if the listeners and clients are available for connection.

Once we know their status we will update our DB table to say that they are online or offline.

has anyone ever put this in place and could anyone suggest best way to do this?
* tcpipC#

Avatar of undefined
Last Comment
ambience

8/22/2022 - Mon
it_saige

I don't have any examples in front of me, but I have done something like this in the past.  Essentially, you want to setup a UDP Broadcast from the both source computers and target computers.  The source computers send datapackets that contain information that the target computers will use in order to record or connect to them source computer.  The target computers will send datapackets that let the source computers know that they are online.

You could do a search for Network Discovery or AutoDiscover Services if you want to learn more about it, but a decent example can be found here:

http://www.nullskull.com/a/1551/clientserver-autodiscovery-in-c-and-udp-sockets.aspx

-saige-
ASKER CERTIFIED SOLUTION
ambience

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
razza_b

ASKER
thanks for feedback guys the way I see it is if I were to send a message and no response back within a certain time period I'd say that's offline, as surely some message would return otherwise(depending on the setup at the other end).

if its a server then wait on clients reconnecting or if i'm the client I then need to reconnect back into the server from which I disconnected form.
ambience

IF nothing is listening on a port an immediate TCP level error will be returned. If the host is down it would take TCP upto ConnectionTimeout to return an error. You can alter the default connection timeout.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy