Hello from France Everybody
I'm new to Perl
but I do want something in Perl equivalent to

http://www.foundstone.com/knowledge/proddesc/fport.html

I really dont know how to do that

Christian Thomas


----- Original Message -----
From: "Ronan Oger" <[EMAIL PROTECTED]>
To: "George C Mccone" <[EMAIL PROTECTED]>; "$Bill Luebkert"
<[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Tuesday, October 22, 2002 9:29 AM
Subject: RE: How does one know if a port is already in use


> George McCone
>
> Why don't you try to ping that port to see if you get a reply. (Granted,
if
> the port ignores pings from your address, then you will think the port is
> closed, but this is at least close to what you want).
>
> You can also maybe simply run a scanning tool to check the port.
>
> Ronan
>
> >-----Original Message-----
> >From: [EMAIL PROTECTED]
> >[mailto:activeperl-admin@;listserv.ActiveState.com]On Behalf Of George C
> >Mccone
> >Sent: Tuesday, October 22, 2002 1:26 AM
> >To: $Bill Luebkert
> >Cc: [EMAIL PROTECTED];
> >[EMAIL PROTECTED]
> >Subject: Re: How does one know if a port is already in use
> >
> >
> >
> >The problem with that is no other process other than the one that I write
> >would write to this file. If someone else is using ports I would have no
> >knowledge.
> >
> >George McCone
> >720-858-4150
> >Raytheon System Company
> >EMOS Integrator
> >
> >
> >
> >
> >
> >                      "$Bill Luebkert" <[EMAIL PROTECTED]>
> >
> >
> >                      Sent by:                               To:
> >   George C Mccone <[EMAIL PROTECTED]>
> >
> >                      [EMAIL PROTECTED]         cc:
> >   [EMAIL PROTECTED]
> >
> >                      veState.com
> >Subject: Re: How does one know if a port is already in use
> >
> >
> >
> >
> >
> >
> >
> >                      10/21/2002 05:12 PM
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >George C Mccone wrote:
> >> I am trying to create a client/sever app that uses IO:Socket:INET.
> >>
> >> When one starts up the server, I want the server to find the first
> >> available port ( in a given range)
> >> and start listening for client connections.
> >>
> >> On Unix, the creation of a new IO:Socket:INET object will fail if
someone
> >> is already bound to that port, but
> >> in Windows it returns an object and all looks good, but you will not be
> >> able to receive until the process
> >> that first bound to the port releases it. Then and only then do I start
> >to
> >> receive the data.
> >>
> >> the following scripts illustrate my point
> >>
> >> Server script
> >> --------------------
> >> #!/usr/local/bin/perl
> >> # -wd:ptkdb
> >>
> >> use strict;
> >> use IO::Socket;
> >> use IO::Select;
> >>
> >> my $port = 7000;
> >>
> >> my $listeningSocket = IO::Socket::INET -> new (Proto => 'tcp',
> >>                                                LocalPort => $port,
> >>                                                Listen => 1,
> >>                                                Reuse => 1) or die $!;
> >> my $client = $listeningSocket->accept();
> >> while(1)
> >> {
> >>         my $data = <$client>;
> >>         print $data;
> >> }
> >>
> >>
> >> Client script
> >> -----------------------
> >> #!/usr/local/bin/perl
> >> # -wd:ptkdb
> >>
> >> use strict;
> >> use IO::Socket;
> >> use IO::Select;
> >>
> >> my $port = 7000;
> >> my $ip = "localhost";
> >>
> >> my $clientSocket = IO::Socket::INET -> new (PeerAddr => $ip,
> >>                                             PeerPort => $port,
> >>                                             Proto => 'tcp') or die $1;
> >>
> >> while (1)
> >> {
> >>         sleep 2;
> >>         $clientSocket->send("message from client\n");
> >> }
> >>
> >>
> >> Now if you start two separate instances of the Server script , and then
> >> start the client. The first instance of the server will receive the
> >> message. Now stop the first instance of the server and restart the
> >client.
> >> Now the second instance of the server starts receiving the message.
> >>
> >> What I would like to do is have the second instance of the server know
> >the
> >> port is not available, because of the other server script is running or
a
> >> multitude of other reasons, increment the port number and try again.
> >>
> >> Anybody have an idea????
> >
> >On UNIX (if you had the same situation which you probably wouldn't), I
> >would create a pid:port file that told which process was listening on
> >which port.  If the pid was not in the process list, I would remove
> >it from the list when checking.  Locks would be appropriate while
modifying
> >the pid:port file.
> >
> >
> >--
> >   ,-/-  __      _  _         $Bill Luebkert   ICQ=162126130
> >  (_/   /  )    // //       DBE Collectibles   Mailto:dbe@;todbe.com
> >   / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
> >-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic
> >http://www.todbe.com/
> >
> >_______________________________________________
> >ActivePerl mailing list
> >[EMAIL PROTECTED]
> >To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> >
> >
> >
> >
> >
> >_______________________________________________
> >ActivePerl mailing list
> >[EMAIL PROTECTED]
> >To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> >
> >
> >
> >
>
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to