ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-unix-users
perl-unix-users
[Perl-unix-users] Socket connections
by Glen Pierce other posts by this author
Jun 6 2007 11:37AM messages near this date
Re: [Perl-unix-users] allowing for a custom time window specification and then calculating if a date/time is within its range | Re: [Perl-unix-users] Socket connections
Hi All,

  I am hoping someone here can help me.  First I will say I don't have a
lot of experience setting up socket connections.  I am trying to set up
a socket connection using IO::Socket.  I want to establish a socket
connection and keep it established.  Can this be done?  If so, what is
the best way to do it?  Also, is there a way to test to see if there is
a socket connection already open on a certain port, other than netstat?
Something internal to perl or the module itself is what I was looking
for.  Below is the snipet of code I am using.

Use IO::Socket;

if (! $socket){

   $socket = IO::Socket::INET-> new(PeerAddr => $ host, PeerPort => $
port, Proto =>  $protocol);

   $socket-> bind();

}

if ($socket) {

    ...do something like send data

}else{

   ...make sure no connections on port I want to use and then 

   open a new socket connection

}

Thanks, 
Glen. 
Thread:
Glen Pierce
Bill Luebkert

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved