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?
LVL 1
razza_bAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it_saigeDeveloperCommented:
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-
0
ambienceCommented:
The only sure way to tell that is to actually connect to the listener and drop the connection immediately. Using any other procotol like UDP (as suggested by others) may or may not work. Think about it this way:

Say all listeners are behind firewall (on port 99). The firewall has hole to allow connection on port 99 for TCP only. Such a setup is likely to occur in any reasonably well protected environment. This is therefore the only rule that you can safely rely upon, any other rule can change.

Also, even in non-firewall cases, just because another PORT/PROTOCOL combination is UP, doesnt mean TCP listeners are also serving (what if too much load/backlog is preventing TCP conn? a hung thread, frozen process). Similarly, a UDP down does not mean listeners are also down.

However, if you are 100% that such a situation will never arise, say if developing a custom solution for internal deployment then you can use other means. The question still remains: WHY add complexity? Keep It Simple Stupid (the Kiss rule).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
razza_bAuthor Commented:
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.
0
ambienceCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
tcpip

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.