// JP opened flex table

Click to See Complete Forum and Search --> : Implementing some broadcast udp protocol


AliJ
February 23rd, 2007, 09:19 AM
Hi !

I need to implement udp protocol in C#/VB.Net Win Forms that send some request to the broadcast address from specific port and then change to be client and receive multiple answers from the broadcast on the same specific port.
My questions are:
1.Is the first connection should use blocking (synchronous) functions ?
2.Should I close this first socket,and then open another one on the same port in order to get the broadcast answers ?
3.In which way should I get the broadcast answers:a.using asynchronous function and events like BeginSend/EndSend etc or b.using threads ?
4.How do I get multiple answers on the same port in this case ?

I will be glad to get answers/code snippets.

Tnx
AliJ

sreehari
February 24th, 2007, 01:42 AM
Hi !
My questions are:
1.Is the first connection should use blocking (synchronous) functions ?


AFAIK you can have it anyway,depending on your requirements, design.

2.Should I close this first socket,and then open another one on the same port in order to get the broadcast answers ?[
No, you dont have to. if the SO_BROADCAST option has been set correctly, then your socket should be able to send and receive all broadcasted frames.
Once the broadcast option has been set then for broadcasting a frame, you should use the ip xxx.xxx.xxx.255


[quote]
4.How do I get multiple answers on the same port in this case ?


what do you mean by Multiple answers ??

AliJ
February 24th, 2007, 04:17 PM
Tnx for your answer.

By this protocol, after sending the broadcast message,the computer which send the broadcast message should get many messages from the servers which are listening on the Lan.The problem arrives when getting this messages.How shuld I implement this scenario ?

thank again.

sreehari
February 26th, 2007, 01:40 AM
One simple way would be reading on the port, in a loop, till your read request times out, as all the datagrams that are received will be present in the socket for the application to read it.

//JP added flex table