How to do Network discovery using UDP Broadcast C#?

Computer networks udp connection problem?

  • hi, i have a problem: Write an UDP broadcast application that serves as client and server in the same time. The application is started with the network broadcast address <NBCAST> as argument in the command line. Upon launching the application listens on UDP port 7777. Every 3 seconds the application sends a UDP broadcast message to NBCAST port 7777 with the format: TIMEQUERY\0 (string) Whenever the application receives a TIMEQUERY demand it answers to the source IP:port with a string message: TIME HH:MM:SS\0 (current time) using unicast. Every 10 seconds the application sends a UDP broadcast message to NBCAST port 7777 with the format: DATEQUERY\0 (string) Whenever the application receives a DATEQUERY demand it answers to the source IP:port with a string message: DATE DD:MM:YYYY\0 (current date) using unicast. The application will keep a list of peers (that answer to broadcast – IP:portno) and update the information anytime a unicast message is received upon a broadcast. When an entry in a list does not have any answer for 3 consecutive broadcasts it will be removed from the list. The list will be displayed (ip,date, time) on the screen upon each update (using a screen positioning api like conio or by erasing the screen before each update). Every malformed request/response received will be counted and displayed at the end of a screen update. now i know how to send the TIMEQUERY and DATEQUERY but i dont know how to receive and send abreast.should i use threads for that? because the recvfrom (which is the only one i could use to keep in list whereof i get a message) waits until it receives something and i cant continue sending.or are there more methods to solve my problem? thanks in advance.

  • Answer:

    Refresh the connection... Good luck!

blaszlo at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.