Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
good chemistry is complicated,
and a little bit messy-LW
 
PerlMonks

UDP socket: Operation not supported

by chrism01 (Friar)
 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

on Dec 20, 2004 at 07:21 UTC ( #416119=perlquestion: print w/ replies, xml ) Need Help??
chrism01 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I'm having trouble creating a basic UDP listen socket. Should be easy...
#!/usr/bin/perl -w use POSIX; use IO::Socket; use IO::Select; use strict; my ( $listen_socket, # socket to listen on $socket_errmsg # error msg if socket not created ); $listen_socket = IO::Socket::INET->new( LocalAddr =>'a.b.c.d', LocalPort => 7172, Proto => 'udp', Listen => 5, Reuse => 1 ) or $socket_errmsg = "Can't make server listen socket : $@\n"; if( !$listen_socket ) { print $socket_errmsg."\n"; }

and the response is:
Can't make server listen socket : IO::Socket::INET: Operation not supported
Any ideas?
Cheers
Chris

Comment on UDP socket: Operation not supported
Download Code
Re: UDP socket: Operation not supported
by edan (Curate) on Dec 20, 2004 at 07:38 UTC

    You can't "Listen" on UDP sockets, only TCP, since UDP is a connectionless protocol - it's a message-passing protocol. If you drop the "Listen" parameter to the new(), you'll find that you'll be able to create the socket. You'll then want to call $sock->recv() (with the appropriate arguments), which will block until you receive a message...

    HTH

    --
    edan

      Thx: worked a treat on my RH FC3, but tgt is FreeBSD 5.3-RELEASE-p2, which came up with:
      Can't make server listen socket : IO::Socket::INET: Can't assign requested address
      any ideas?

        This doesn't have anything to do with the operating system. It means you are trying to bind to a local IP address that isn't found on any interface on the host. Did you change the

        LocalAddr => 'a.b.c.d'
        argument to an appropriate local address on the FreeBSD box, or are you trying to bind to the address on the RH box? Do you really care which address you bind to locally? You could just leave this argument out to bind to '*' - that would make life easier...

        --
        edan

Login:
Password
remember me
What's my password?
Create A New User

Node Status?
node history
Node Type: perlquestion [id://416119]
Approved by edan
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (21)
jdporter
holli
Gavin
JavaFan
CardinalNumber
jwkrahn
kennethk
thezip
Eyck
LanX
hangon
pemungkah
state-o-dis-array
ssandv
draegtun
BenHopkins
MikeDexter
jmccarrell
tomerb
David S
Spakz
As of 2010-02-09 22:51 GMT
Sections?
The Monastery Gates
Seekers of Perl Wisdom
Meditations
PerlMonks Discussion
Categorized Q&A
Tutorials
Obfuscated Code
Perl Poetry
Cool Uses for Perl
Perl News
Information?
PerlMonks FAQ
Guide to the Monastery
What's New at PerlMonks
Voting/Experience System
Tutorials
Reviews
Library
Perl FAQs
Other Info Sources
Find Nodes?
Nodes You Wrote
Super Search
List Nodes By Users
Newest Nodes
Recently Active Threads
Selected Best Nodes
Best Nodes
Worst Nodes
Saints in our Book
Leftovers?
The St. Larry Wall Shrine
Offering Plate
Awards
Craft
Snippets Section
Code Catacombs
Quests
Editor Requests
Buy PerlMonks Gear
PerlMonks Merchandise
Planet Perl
Perlsphere
Use Perl
Perl.com
Perl 5 Wiki
Perl Jobs
Perl Mongers
Perl Directory
Perl documentation
CPAN
Random Node
Voting Booth?

What level of existential comfort do you require?

Palace
Executive suite at the best hotel
Regular hotel in a decent part of town
Motel
Boarding house
Sleeping Bag on Couch in Basement
Any port in a storm
Camping under the freeway overpass
Jail
Other

Results (283 votes), past polls