Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Perl Monk, Perl Meditation
 
PerlMonks  

How to get remote address in Socket after accept?

by anaconda_wly (Scribe)
on Jan 14, 2013 at 09:39 UTC ( #1013177=perlquestion: print w/ replies, xml ) Need Help??
anaconda_wly has asked for the wisdom of the Perl Monks concerning the following question:

I write a receive sub to get remote message, how can I get the requester's address after accept a new link request from remote? The receiving thread sub as below:

sub _receive { my $port = shift; my $sock = new IO::Socket::INET (LocalPort => $port,Proto => 'tcp' +,Listen => 1,Reuse => 1,); die "Could not create socket: $!\n" unless $sock; $listeningCreated = 1; while(not $isFinishing) { my $new_sock = $sock->accept(); print "New updates from targets arrival:\n"; while(<$new_sock>) { print $_; } } close($sock); return 0; }

How can I do based on the current code? It works OK currently. But I want to do the remote address. Thanks!

Comment on How to get remote address in Socket after accept?
Download Code
Re: How to get remote address in Socket after accept?
by Anonymous Monk on Jan 14, 2013 at 10:06 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2014-04-20 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls