Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# Auto Discovery

Posted on 2016-07-26
4
Medium Priority
?
181 Views
Last Modified: 2016-07-26
I found this article that contains code on a client / server application can communicate with each other without knowing their IP address prior the the first network handshake.  The article discusses using UDP.

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

My understanding of UDP is that it is not as secure as TCP.  

Is there a TCP example?
Or any other advice?  I need a client to auto discover a server app without knowing the IP.  I know bonjour is a possibility but looking for another solution.

Thanks
0
Comment
Question by:CipherIS
  • 2
  • 2
4 Comments
 
LVL 35

Expert Comment

by:it_saige
ID: 41729734
For this situation you want to use UDP.  It doesn't have to be secure because you are not making a secure connection, instead you are sending a network wide signal.  It's basically a ping.  For this ping you want the smaller footprint that a UDP packet allows for.  Anyone that is listening for the ping responds.

After you receive the ping acknowledgement do you attempt to make the secure tcp connection.  I believe that you think that you have to use a different port than that of which you currently use but that is not the case.

TCP/80 is not the same as UDP/80 (not implying that this is the port you use).

WCF even implements helper classes for UdpDiscovery:  https://msdn.microsoft.com/en-us/library/dd456791(v=vs.110).aspx

-saige-
0
 
LVL 1

Author Comment

by:CipherIS
ID: 41729930
Saige,

So if I understand correct, use UDP for the ping.  Once I receive the acknowledgement, then switch to TCP to make the secure connection?

Thanks
0
 
LVL 35

Accepted Solution

by:
it_saige earned 2000 total points
ID: 41729943
Exactly.  The information that you send back, is supposed to carry an acknowledgement, ip address and a port (if required).  The client then takes the acknowledgement and connects to the ip address and port using whatever mechanism you employ to secure tcp communications.

-saige-
0
 
LVL 1

Author Comment

by:CipherIS
ID: 41730200
I wouldn't have to worry about the security issues with UDP (e.g. DOS)?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question