Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Answer to a UDP Broadcast is ignored

by VinsWorldcom (Vicar)
on Apr 29, 2013 at 11:51 UTC ( #1031198=note: print w/ replies, xml ) Need Help??


in reply to Answer to a UDP Broadcast is ignored

UDP is connectionless so you probably won't be able to send/receive on a single socket pair (bi-directional). Have you tried opening a listening socket on port 58255 (LocalPort) and having that 'recv' the response as it will be unicast to you? For example

use strict; use warnings; [...] my $FindCard = IO::Socket::INET->new(Proto=>"udp",LocalPort=>58255,Pee +rPort=>55777,PeerAddr=>"192.168.11.255",Broadcast=>1) or die "Can't make UDP socket: $@"; my $recv = IO::Socket::INET->new(Proto=>"udp",LocalPort=>58255) or die "Can't make UDP socket: $@"; [...] $FindCard->send(""); $recv->recv($datagram,120,$flags); [...]


Comment on Re: Answer to a UDP Broadcast is ignored
Download Code
Re^2: Answer to a UDP Broadcast is ignored
by Anonymous Monk on Apr 30, 2013 at 07:17 UTC
    Thank you very much! Alltough your code doesn't work this way, you gave me the right hint:
    The way your code works i have a problem that i open the same socket twice. That don't work.
    I tried "ReuseSocket", but it seems my OS (Linux MINT) doesn't support that. So first i opened the Socket, send my Broadcast, closed it an reopened the socket the way you suggested. I'm aware that if the card answers to fast i will have a Problem cause my socket may not be open at that time... i'll have to do some testing.
    But know i receive the Answer and can extract the strings i'm looking for.

    Thanks again!

    Regards,
    Sven

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031198]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2015-07-07 12:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls