Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: TCP Server timeout

by leighsharpe (Monk)
on Feb 23, 2010 at 03:59 UTC ( [id://824756]=note: print w/replies, xml ) Need Help??


in reply to TCP Server timeout

The 'timeout' option to IO::Socket will do what you want:
#!/usr/bin/perl use strict; use warnings; use IO::Socket; my $server=IO::Socket->new( Domain=>AF_INET, Proto=>'tcp', LocalPort=>'1234', Listen=>SOMAXCONN, ); $server->timeout(10); my $connection=$server->accept; if ($connection) { print "Got a message.\n"; close $connection; } else { print "Timed out.\n"; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-19 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found