Re: IO::Socket::Multicast::mcast_send

2020-04-05 Thread James Kerwin
A I managed to find the problem thanks to somebody else finding it late
last year.

With the particular verison of Perl on the Pi (I think I said 5.28) there
is a bug for the IO::Socket::Multicast module:

https://rt.cpan.org/Public/Bug/Display.html?id=130581

To fix it I went in to where the Multicast.pm file lives and implemented
the suggested changes.

I know the correct thing to do was probably to make a local copy of the
file and point to it, or switch to a younger version of Perl, but it's a
personal project on a Pi that I'm likely to wipe in a few months.

Script(s) work now!

Thanks for the help.

James


On Sun, Apr 5, 2020 at 4:03 PM Shlomi Fish  wrote:

> Hi James,
>
> On Sun, 5 Apr 2020 14:58:26 +0100
> James Kerwin  wrote:
>
> > Hi All,
> >
> > I'm trying to connect to a smart bulb on my home WIFI using mcast_send
> > in IO::Socket::Multicast.
> >
> > It works on my main Linux Mint laptop. The same script does not work on
> my
> > Raspberry PI.
> >
> > Despite the script running as expected on one laptop I've checked that
> this
> > is all set up correctly:
> >
> > sub new {
> > #my $class = shift;
> > my $data  = {
> > address => '239.255.255.250',
> > port=> 1982,
> > timeout => 3,
> > devices => [],
> > };
> > return bless( $data );
> > }
> >
>
> It is a good idea to use bless with an explicit package name or just use
> https://metacpan.org/pod/Moo or Moose or similar.
>
> > my $socket = IO::Socket::Multicast->new(
> > PeerAddr  => $self->{address},
> > PeerPort  => $self->{port},
> > Proto => "udp",
> > ReuseAddr => 1,
> > ) or croak $!;
> >
> > But it's this part that fails on the PI:
> >
>
> A few things to check:
>
> 1. Which OS/distro/version and perl version  on both machines?
>
> 2. Does it happen with the latest stable perl installed from source?
>
> 3. Did you try using https://en.wikipedia.org/wiki/GDB and/or perl -d:
> https://perl-begin.org/topics/debugging/ ?
>
> 4. Is there anything in the rpi's firewall config?
>
> For more advice, see
> https://github.com/shlomif/writing-the-perfect-question .
>
> > $socket->mcast_send( $query, "$self->{address}:$self->{port}" ) or croak
> $!;
> >
> > I've checked that $socket, $query and $self->{address}:$self->{port}
> > contain the info I expect and they do.
> >
> > On my Linux laptop I can use tcpdump and see the communication between
> > laptop and bulb. Doing this on the Pi shows no communication. I've
> replaced
> > the "croak" with "die "" so I can be certain it's failing at
> > that point. I get the output "" (makes it easier to spot).
> >
> > I've just used a command recently that allows me to access the specific
> ip
> > and port of the lamp and it indicates the connection is successful. I'm
> out
> > of ideas and if anyone can advise I'd appreciate it.
> >
> > Slightly (very) out of my depth when it comes to ports and IPs etc.
> >
> > Thanks,
> > James
>
>
>
> --
>
> Shlomi Fish   https://www.shlomifish.org/
> https://github.com/shlomif/validate-your-html - Validate Your HTML
>


Re: IO::Socket::Multicast::mcast_send

2020-04-05 Thread James Kerwin
Hi thanks for the response.

Before I continue, at the top of the script I first borrowed for this it
had "use 5.026;". When I remove this and then alter any "say" or "break"
etc that appear the scripts continue to work as before; Mint laptop works,
Pi does not.

1) For PI:
Pi Raspbian GNU/Linux 10 (buster).
Perl Version: v5.28.1 (installed with OS).

ufw is not installed. I don't THINK any other firewalls are installed. I
haven't installed any and I don't think there's one by default. This was a
fresh install of Rasbpian done just this week.

Looking at iptables:
$ sudo iptables -L -nv
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target prot opt in out source
destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target prot opt in out source
destination

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target prot opt in out source
destination

For Linux:
Linux Mint 18 (Sarah)
Perl: v5.26.0 (switched using perlbrew if memory serves me correctly. Some
modules wouldn't install due to the Perl version that came with the OS).

ufw is disabled. When I activate it the script does not work, but it
doesn't give an error pointing at the line where $socket->mcast_send is
called, as it does on the pi.

iptables gives a massive output.

2) I have not tried it with the latest stable version of Perl, partly
because I have several different versions of Perl where it does/doesn't
work and I'd mentally ruled out the Perl version. For example it doesn't
work with the Perl on my Windows laptop, but doesn't give an error so my
suspicion there is it's something firewall related.

3) I will check out those links. I've just quickly looked through the
script on the laptop with the debugger. I'll go check with the pi when I
can get back on it (plugged in to TV, Tv in use).

4) Mentioned this in 1.

I'll keep at it for now, and keep trying things. I am able to identify the
bulb when I log into the router and can directly ping the ip from the
laptop and pi.

Thanks,
James

On Sun, Apr 5, 2020 at 4:03 PM Shlomi Fish  wrote:

> Hi James,
>
> On Sun, 5 Apr 2020 14:58:26 +0100
> James Kerwin  wrote:
>
> > Hi All,
> >
> > I'm trying to connect to a smart bulb on my home WIFI using mcast_send
> > in IO::Socket::Multicast.
> >
> > It works on my main Linux Mint laptop. The same script does not work on
> my
> > Raspberry PI.
> >
> > Despite the script running as expected on one laptop I've checked that
> this
> > is all set up correctly:
> >
> > sub new {
> > #my $class = shift;
> > my $data  = {
> > address => '239.255.255.250',
> > port=> 1982,
> > timeout => 3,
> > devices => [],
> > };
> > return bless( $data );
> > }
> >
>
> It is a good idea to use bless with an explicit package name or just use
> https://metacpan.org/pod/Moo or Moose or similar.
>
> > my $socket = IO::Socket::Multicast->new(
> > PeerAddr  => $self->{address},
> > PeerPort  => $self->{port},
> > Proto => "udp",
> > ReuseAddr => 1,
> > ) or croak $!;
> >
> > But it's this part that fails on the PI:
> >
>
> A few things to check:
>
> 1. Which OS/distro/version and perl version  on both machines?
>
> 2. Does it happen with the latest stable perl installed from source?
>
> 3. Did you try using https://en.wikipedia.org/wiki/GDB and/or perl -d:
> https://perl-begin.org/topics/debugging/ ?
>
> 4. Is there anything in the rpi's firewall config?
>
> For more advice, see
> https://github.com/shlomif/writing-the-perfect-question .
>
> > $socket->mcast_send( $query, "$self->{address}:$self->{port}" ) or croak
> $!;
> >
> > I've checked that $socket, $query and $self->{address}:$self->{port}
> > contain the info I expect and they do.
> >
> > On my Linux laptop I can use tcpdump and see the communication between
> > laptop and bulb. Doing this on the Pi shows no communication. I've
> replaced
> > the "croak" with "die "" so I can be certain it's failing at
> > that point. I get the output "" (makes it easier to spot).
> >
> > I've just used a command recently that allows me to access the specific
> ip
> > and port of the lamp and it indicates the connection is successful. I'm
> out
> > of ideas and if anyone can advise I'd appreciate it.
> >
> > Slightly (very) out of my depth when it comes to ports and IPs etc.
> >
> > Thanks,
> > James
>
>
>
> --
>
> Shlomi Fish   https://www.shlomifish.org/
> https://github.com/shlomif/validate-your-html - Validate Your HTML
>


Re: IO::Socket::Multicast::mcast_send

2020-04-05 Thread Shlomi Fish
Hi James,

On Sun, 5 Apr 2020 14:58:26 +0100
James Kerwin  wrote:

> Hi All,
> 
> I'm trying to connect to a smart bulb on my home WIFI using mcast_send
> in IO::Socket::Multicast.
> 
> It works on my main Linux Mint laptop. The same script does not work on my
> Raspberry PI.
> 
> Despite the script running as expected on one laptop I've checked that this
> is all set up correctly:
> 
> sub new {
> #my $class = shift;
> my $data  = {
> address => '239.255.255.250',
> port=> 1982,
> timeout => 3,
> devices => [],
> };
> return bless( $data );
> }
> 

It is a good idea to use bless with an explicit package name or just use
https://metacpan.org/pod/Moo or Moose or similar.

> my $socket = IO::Socket::Multicast->new(
> PeerAddr  => $self->{address},
> PeerPort  => $self->{port},
> Proto => "udp",
> ReuseAddr => 1,
> ) or croak $!;
> 
> But it's this part that fails on the PI:
> 

A few things to check:

1. Which OS/distro/version and perl version  on both machines?

2. Does it happen with the latest stable perl installed from source?

3. Did you try using https://en.wikipedia.org/wiki/GDB and/or perl -d:
https://perl-begin.org/topics/debugging/ ?

4. Is there anything in the rpi's firewall config?

For more advice, see https://github.com/shlomif/writing-the-perfect-question .

> $socket->mcast_send( $query, "$self->{address}:$self->{port}" ) or croak $!;
> 
> I've checked that $socket, $query and $self->{address}:$self->{port}
> contain the info I expect and they do.
> 
> On my Linux laptop I can use tcpdump and see the communication between
> laptop and bulb. Doing this on the Pi shows no communication. I've replaced
> the "croak" with "die "" so I can be certain it's failing at
> that point. I get the output "" (makes it easier to spot).
> 
> I've just used a command recently that allows me to access the specific ip
> and port of the lamp and it indicates the connection is successful. I'm out
> of ideas and if anyone can advise I'd appreciate it.
> 
> Slightly (very) out of my depth when it comes to ports and IPs etc.
> 
> Thanks,
> James



-- 

Shlomi Fish   https://www.shlomifish.org/
https://github.com/shlomif/validate-your-html - Validate Your HTML

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: IO::Socket

2014-12-29 Thread Andrew Solomon
This might be a good place to start: https://metacpan.org/pod/Socket

On Mon, Dec 29, 2014 at 4:23 PM, Mike ekimduna...@gmail.com wrote:
 Can anyone point me in the direction of more thorough documentation for the
 IO::Socket module? Seems like the documentation on perl.org is pretty
 limited. At least, it doesn't feel very thorough to me.

 http://perldoc.perl.org/IO/Socket.html

 For example, what exactly does timeout affect?

 This documentation also doesn't explain what values the methods accept or
 how to use them.

 Thanks.

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/





-- 
Andrew Solomon

Mentor@Geekuni http://geekuni.com/
http://www.linkedin.com/in/asolomon

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: IO::Socket

2014-12-29 Thread Brandon McCaig
Mike:

On Mon, Dec 29, 2014 at 10:23:00AM -0600, Mike wrote:
 Can anyone point me in the direction of more thorough
 documentation for the IO::Socket module? Seems like the
 documentation on perl.org is pretty limited. At least, it
 doesn't feel very thorough to me.
 
 http://perldoc.perl.org/IO/Socket.html
 
 For example, what exactly does timeout affect?
 
 This documentation also doesn't explain what values the methods
 accept or how to use them.

I believe that IO::Socket is intended to be a Perl OO wrapper
around the raw UNIX socket concept (and WinSock's concept of an
Internet socket copied from Berkeley's implementation) and its
raw Perl wrapper (e.g., Socket.pm). I guess the documentation
relies on knowledge of this underlying API and/or reference to
its documentation.

There appears to be a send timeout and a receive timeout
option for UNIX sockets, though the documentation says that not
all implementations support it. Since Perl's OO wrapper only
seems to have one I can only assume that the timeout applies to
both read and write operations on the socket. At least shy of
accessing the source code to see for myself.

...read read read...

It appears that IO::Socket's timeout is unrelated to the
afforementioned send and receive timeout options (though those
could potentially still be accessed using the raw
/(get|set)sockopt/ functions)..

The IO::Socket source appears to construct an IO::Select object
with the timeout value and then waits until you can either read
or write, depending on what's applicable, or the timeout is
elapsed. This appeared to only affect connect() and accept()
methods. Though the documentation cited this by saying that it's
horribly inefficient to do this since the IO::Select object is
constructed just for this one purpose and that using select() or
non-blocking IO is preferred.

Truly understanding the implenetation details may require dipping
into IO::Select's source too and following it all back to C. I
can't be bothered. I think that to understand what's going on
here you need experience programming raw sockets in C.

While raw socket access is a useful skill (mostly for a C
programmer), I think that older and wiser Perl hackers would
encourage the use of higher-level, event-based wrappers for
networking in Perl to save yourself the trouble of reinventing
the square wheel. YMMV. Raw socket access or experience shouldn't
really be necessary if using one of the higher-level wrappers so
you can spare yourself the nightmares if all you need is
networking. :)

Regards,


-- 
Brandon McCaig bamcc...@gmail.com bamcc...@castopulence.org
Castopulence Software https://www.castopulence.org/
Blog http://www.bamccaig.com/
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'



signature.asc
Description: Digital signature


Re: IO::Socket::SSL and SSL_verify_mode

2012-03-21 Thread Bob goolsby
What was wrong with the answer you received on Perl Monks?




2012/3/21 ml m...@smtp.fakessh.eu:
 hello list
 hello guru of perl
 hello all


 I seek to understand how to position the value SSL_verify_mode = 0x00.

        can you explain how to properly use this parameter in
        IO::Socket::SSL

 thank for reply

 sincerely

 --
 http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC2626742
  gpg --keyserver pgp.mit.edu --recv-key C2626742

  http://urlshort.eu fakessh @
  http://gplus.to/sshfake
  http://gplus.to/sshswilting
  http://gplus.to/john.swilting
  https://lists.fakessh.eu/mailman/
  This list is moderated by me, but all applications will be accepted
  provided they receive a note of presentation



-- 

Bob Goolsby
bob.gool...@gmail.com

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: IO::Socket::SSL and SSL_verify_mode

2012-03-21 Thread ml
and though I can walk to my client and server with 0x00
when i put another value of 0x02 0x03 0x04 my script fails at the
function
#-
# nonblock($socket) puts socket into nonblocking mode
sub nonblock {
my $socket = shift;
my $flags;


$flags = fcntl($socket, F_GETFL, 0)
or die Can't get flags for socket: $!\n;
fcntl($socket, F_SETFL, $flags | O_NONBLOCK)
or die Can't make socket nonblocking: $!\n;
}


what my client server product that works only with 0x00

Le mercredi 21 mars 2012 à 17:33 -0700, Bob goolsby a écrit :
 What was wrong with the answer you received on Perl Monks?
 
 
 
 
 2012/3/21 ml m...@smtp.fakessh.eu:
  hello list
  hello guru of perl
  hello all
 
 
  I seek to understand how to position the value SSL_verify_mode = 0x00.
 
 can you explain how to properly use this parameter in
 IO::Socket::SSL
 
  thank for reply
 
  sincerely
 
  --
  http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC2626742
   gpg --keyserver pgp.mit.edu --recv-key C2626742
 
   http://urlshort.eu fakessh @
   http://gplus.to/sshfake
   http://gplus.to/sshswilting
   http://gplus.to/john.swilting
   https://lists.fakessh.eu/mailman/
   This list is moderated by me, but all applications will be accepted
   provided they receive a note of presentation
 
 
 
 -- 
 
 Bob Goolsby
 bob.gool...@gmail.com
 

-- 
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC2626742
 gpg --keyserver pgp.mit.edu --recv-key C2626742

 http://urlshort.eu fakessh @
 http://gplus.to/sshfake
 http://gplus.to/sshswilting
 http://gplus.to/john.swilting
 https://lists.fakessh.eu/mailman/
 This list is moderated by me, but all applications will be accepted
 provided they receive a note of presentation


signature.asc
Description: Ceci est une partie de message numériquement signée


Re: IO::Socket::SSL and SSL_verify_mode

2012-03-21 Thread ml
my error in my server script is 
Can't use an undefined value as a symbol reference at server.pl ligne
412

ligne 412 is
$flags = fcntl($socket, F_GETFL, 0)or die Can't get flags for socket:
$!\n;

Please explain me clearly

Le jeudi 22 mars 2012 à 01:45 +0100, ml a écrit :
 and though I can walk to my client and server with 0x00
 when i put another value of 0x02 0x03 0x04 my script fails at the
 function
 #-
 # nonblock($socket) puts socket into nonblocking mode
 sub nonblock {
 my $socket = shift;
 my $flags;
 
 
 $flags = fcntl($socket, F_GETFL, 0)
 or die Can't get flags for socket: $!\n;
 fcntl($socket, F_SETFL, $flags | O_NONBLOCK)
 or die Can't make socket nonblocking: $!\n;
 }
 
 
 what my client server product that works only with 0x00
 
 Le mercredi 21 mars 2012 à 17:33 -0700, Bob goolsby a écrit :
  What was wrong with the answer you received on Perl Monks?
  
  
  
  
  2012/3/21 ml m...@smtp.fakessh.eu:
   hello list
   hello guru of perl
   hello all
  
  
   I seek to understand how to position the value SSL_verify_mode = 0x00.
  
  can you explain how to properly use this parameter in
  IO::Socket::SSL
  
   thank for reply
  
   sincerely
  
   --
   http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC2626742
gpg --keyserver pgp.mit.edu --recv-key C2626742
  
http://urlshort.eu fakessh @
http://gplus.to/sshfake
http://gplus.to/sshswilting
http://gplus.to/john.swilting
https://lists.fakessh.eu/mailman/
This list is moderated by me, but all applications will be accepted
provided they receive a note of presentation
  
  
  
  -- 
  
  Bob Goolsby
  bob.gool...@gmail.com
  
 

-- 
http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC2626742
 gpg --keyserver pgp.mit.edu --recv-key C2626742

 http://urlshort.eu fakessh @
 http://gplus.to/sshfake
 http://gplus.to/sshswilting
 http://gplus.to/john.swilting
 https://lists.fakessh.eu/mailman/
 This list is moderated by me, but all applications will be accepted
 provided they receive a note of presentation


signature.asc
Description: Ceci est une partie de message numériquement signée


Re: IO::Socket operations

2010-09-28 Thread Jeff Pang
2010/9/28 Anand Parthiban h3lloan...@gmail.com:


 my $new_sock = $sock-accept();
 while($new_sock) {
 print $_;
 }
 close($sock);
 ###
 --


Put them in a forever loop, like:

while(1) {
   my $conn = $sock-accept();
   print $conn;
}

etc.
You may want to buy the book Network Programming with Perl for any
detail about socket programming.


Jeff.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: IO::Socket operations

2010-09-28 Thread Shlomi Fish
Hi Anand,

On Tuesday 28 September 2010 06:52:26 Anand Parthiban wrote:
 Dear Team,
 
 I am a newbie to PERL,

See http://perl.org.il/misc.html#pl_vs_pl .

 
 I was studying about the Socket programming in perl and I was Doing a
 Sample Programs using IO::Socket
 
 I have Written a Sample Server Client program and it works great,
 
 Now, the Problem is that the server is able to listen on Some ports and
 when the client sends any message,
 
 the server is able to Print the message and exiting , But what i want is
 that the server should able to listen continuosly
 
 after printing that message.
 
 Can Anyone help me how to do this
 
 Thanks in Advance
 
 
 
 THIS IS SERVER PROGRAM
 ###
 #!/usr/bin/perl

Add use strict; and use warnings;. See:

http://perl-begin.org/tutorials/bad-elements/

for more information.

 use IO::Socket;
 my $sock = new IO::Socket::INET (

This should be IO::Socket::INET-new(

 LocalHost = '192.168.0.217',
 LocalPort = '3890',
 Proto = 'tcp',
 Listen = 1,
 Reuse = 1,
 );

Your code needs indentation and empty lines between paragraphs.

 die Could not create socket: $!\n unless $sock;
 my $new_sock = $sock-accept();
 while($new_sock) {
 print $_;
 }




 close($sock);

I believe you're accepting one connection (which blocks further connections), 
handling it, and afterwards exiting from the program. If you want to handle 
one connection at a time you can do while (my $new_sock = $sock-accept()) { 
... }. If you wish to handle several simultaneous connections, look at POE, 
IO::Async, AnyEvent, IO::Lambda, Reflex on  the CPAN.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Star Trek: We, the Living Dead - http://shlom.in/st-wtld

rindolf She's a hot chick. But she smokes.
go|dfish She can smoke as long as she's smokin'.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: IO::Socket::INET client hangs on no server on windoze

2007-05-31 Thread kenTk
On May 29, 7:55 pm, [EMAIL PROTECTED] (kenTk) wrote:
 On May 29, 2:40 pm, [EMAIL PROTECTED] (Zentara) wrote:

  On 28 May 2007 08:28:35 -0700, [EMAIL PROTECTED] (kenTk) wrote:

  If there is no server or no connection this hangs for about 20 seconds
  and then crashes with the following error message.
  The Timeout seems to make no difference and the 'warn' does not occur.
  If works file with a good connection to a server.
  Using 5.8.8 active perl.
  Anyone got any suggestions for making it return undef in an orderly
  fashion?
  (I have tested it on Linux and it seems to work fine both ways)

  use strict;
  use warnings;
  use IO::Socket::INET;

  sub testSocket
  {
my $sock;
my $ok=0;
unless( $sock=IO::Socket::INET-new(192.168.5.41,
   PeerPort = '21',
   Proto= 'tcp',
   Timeout  ='3'))

  are you sure that '21' and  '3' should be quoted?
  Maybe Perl figures it's context and does the right thing on linux?

{  warn 'Cant connect'; }
else
{ $sock-close;  $ok=1; }
   return $ok;
  }

  I don't use win32, but have seen these somewhat related 
  posts:http://perlmonks.org?node_id=567912

 http://perlmonks.org?node_id=529812

  zentara

 I tried removing the quotes around 21 and 3 but with no success.
 I have already tried the ioctl fix for non-blocking on windoze but to
 no avail. I believe that only applies to a new socket object after it
 has been created. In this case that creation process fails with a
 crash and doesnt return in an orderly fashion. I wish that I didn't
 have to use windoze but ..

I have now found that this behaves correctly a couple of other windoze
win32 machines. There must be something bust deep down on this
machine. Strange because I have never seen it on any other application
on this machine.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: IO::Socket::INET client hangs on no server on windoze

2007-05-29 Thread kenTk
On May 29, 2:40 pm, [EMAIL PROTECTED] (Zentara) wrote:
 On 28 May 2007 08:28:35 -0700, [EMAIL PROTECTED] (kenTk) wrote:



 If there is no server or no connection this hangs for about 20 seconds
 and then crashes with the following error message.
 The Timeout seems to make no difference and the 'warn' does not occur.
 If works file with a good connection to a server.
 Using 5.8.8 active perl.
 Anyone got any suggestions for making it return undef in an orderly
 fashion?
 (I have tested it on Linux and it seems to work fine both ways)

 use strict;
 use warnings;
 use IO::Socket::INET;

 sub testSocket
 {
   my $sock;
   my $ok=0;
   unless( $sock=IO::Socket::INET-new(192.168.5.41,
  PeerPort = '21',
  Proto= 'tcp',
  Timeout  ='3'))

 are you sure that '21' and  '3' should be quoted?
 Maybe Perl figures it's context and does the right thing on linux?

   {  warn 'Cant connect'; }
   else
   { $sock-close;  $ok=1; }
  return $ok;
 }

 I don't use win32, but have seen these somewhat related 
 posts:http://perlmonks.org?node_id=567912

 http://perlmonks.org?node_id=529812

 zentara

I tried removing the quotes around 21 and 3 but with no success.
I have already tried the ioctl fix for non-blocking on windoze but to
no avail. I believe that only applies to a new socket object after it
has been created. In this case that creation process fails with a
crash and doesnt return in an orderly fashion. I wish that I didn't
have to use windoze but ..


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: IO::Socket squirreliness

2005-08-25 Thread Mason Loring Bliss
On Wed, Aug 24, 2005 at 04:14:15PM -0400, Bob Showalter wrote:

 A connect() followed by a close() is just another form of this scenario. You
 need to have a client socket in order to detect the peer's closing the
 connection.

That clarifies things quite nicely. Thank you very much!

-- 
 Mason Loring Bliss [EMAIL PROTECTED]http://blisses.org/  
I am a brother of jackals, and a companion of ostriches.  (Job 30 : 29)


pgprZisyRJyf9.pgp
Description: PGP signature


Re: IO::Socket squirreliness

2005-08-24 Thread Mason Loring Bliss
On Tue, Aug 23, 2005 at 11:10:58AM -0400, Mason Loring Bliss wrote:

 Hi, all! I'm learning about dealing with sockets in Perl, and I've got a
 question about some unexpected behaviour exhibited by the following test
 script.
 
 In the case where I open a connection and then close it before
 $socket-accept() is called, I'd expect $socket-accept() to return undef,
 but it never does. Will someone kindly tell me why this is?
 
 Thanks in advance!

Is there a forum other than this one where I might ask this question? I
was hoping that maybe someone here knew the answer and would share it...

Should $socket-accept() return undef if the client in question has died
off before the server has gotten around to accepting() the connection?
Maybe my assumption is faulty, and there's no implicit close happening
when the initiating process dies. I'll explore this possibility.

Hm. No. When the client calls shutdown(2) or close() before the server
calls accept(), the server's $socket-accept still returns with a socket,
and not undef.

Am I missing something fundamental here? Is this a bug in IO::Socket? Is
there some other issue of which I'm unaware?

Thanks in advance for enlightening me.

-- 
 Mason Loring Bliss [EMAIL PROTECTED]http://blisses.org/  
I am a brother of jackals, and a companion of ostriches.  (Job 30 : 29)


pgpmAloJqxY4M.pgp
Description: PGP signature


RE: IO::Socket squirreliness

2005-08-24 Thread Bob Showalter
Mason Loring Bliss wrote:
 On Tue, Aug 23, 2005 at 11:10:58AM -0400, Mason Loring Bliss wrote:
 
 Hi, all! I'm learning about dealing with sockets in Perl, and I've
 got a question about some unexpected behaviour exhibited by the
 following test script. 
 
 In the case where I open a connection and then close it before
 $socket-accept() is called, I'd expect $socket-accept() to return
 undef, but it never does. Will someone kindly tell me why this is?
 
 Thanks in advance!
 
 Is there a forum other than this one where I might ask this question?
 I was hoping that maybe someone here knew the answer and would share
 it... 
 
 Should $socket-accept() return undef if the client in question has
 died off before the server has gotten around to accepting() the
 connection? Maybe my assumption is faulty, and there's no implicit
 close happening when the initiating process dies. I'll explore this
 possibility. 
 
 Hm. No. When the client calls shutdown(2) or close() before the server
 calls accept(), the server's $socket-accept still returns with a
 socket, and not undef.
 
 Am I missing something fundamental here? Is this a bug in IO::Socket?
 Is there some other issue of which I'm unaware?

I don't think there's any problem with IO::Socket. Even if accept returns a
socket, you should receive an EOF on that socket when you try to read from
it, which tells you that the peer has closed the connection. I think you
just need to check for both situations: an error from accept(), and EOF from
read().

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: IO::Socket squirreliness

2005-08-24 Thread Bob Showalter
Bob Showalter wrote:
 I don't think there's any problem with IO::Socket. Even if accept
 returns a socket, you should receive an EOF on that socket when you
 try to read from it, which tells you that the peer has closed the
 connection. I think you just need to check for both situations: an
 error from accept(), and EOF from read().

Another way of looking at it is to suppose that the client connected, sent a
small message, and then disconnected before you called accept(). The kernel
could still maintain this data in its buffers, and you would obviously need
accept to return the socket so you could read the data.

A connect() followed by a close() is just another form of this scenario. You
need to have a client socket in order to detect the peer's closing the
connection.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: IO::Socket::UNIX questions

2004-12-31 Thread Jonathan Paton
On Thu, 30 Dec 2004 22:51:00 -0500, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 ...
  3: Do UNIX sockets have less overhead than INET sockets?

 That all depends, it can go both way's. UNIX sockets, is
 comunicatting through files. Faster way would be to
 communicate through pipe's.

I think communication through files is misleading.

That file is special, it is a named pipe (or named FIFO...).  Just like
/dev/zero and /dev/null, and many of the other files in /dev.  The
pipes always transfer data through memory.

I would hazard a guess that named pipes and anonymous pipes
are implemented using the same code.  The difference is
how the connection is established.

UNIX vs INET is another story.  On loopback, I guess INET would
easily achieve 100MB/sec, and I think UNIX domain sockets
would be faster still.

Jonathan Paton

-- 
#!perl
$J=' 'x25 ;for (qq 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 =~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,= $c+= +$1} warn $J,,

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: IO::Socket::UNIX questions

2004-12-30 Thread Jonathan Paton
 I am working with UNIX Sockets and have some questions
 that I cant seem to find answers to on the web.

Since the questions was interesting enough to me, I thought
I would research the answer.  Perl Cookbook contains an
entire chapter on this.  I am not a socket programmer!

 1: Are UNIX sockets bi-directional?

From man 2 socket (linux):

   SOCK_STREAM
  Provides sequenced,  reliable,  two-way,  connection-based  byte
  streams.  An out-of-band data transmission mechanism may be sup-
  ported.

   SOCK_DGRAM
  Supports datagrams (connectionless,  unreliable  messages  of  a
  fixed maximum length).

If you choose PF_UNIX and SOCK_STREAM, then you would expect
something akin to TCP.  Similarly, PF_UNIX and SOCK_DGRAM
would give something akin to UDP.

So, datagrams are connectionless, and by extension are
one way.  With a datagram, a message is transferred
between processes, and that is that.

 2: If so, what is the proper way to 'setup' the connection? ...

Try choosing SOCK_STREAM instead of SOCK_DGRAM.

 3: Do UNIX sockets have less overhead than INET sockets?

I believe so, but the difference might not be that great.  Which
seams more appropriate?

May the man pages help you in your quest.

Jonathan Paton

-- 
#!perl
$J=' 'x25 ;for (qq 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 =~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,= $c+= +$1} warn $J,,

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: IO::Socket::UNIX questions

2004-12-30 Thread mgoland


- Original Message -
From: Dave Kettmann [EMAIL PROTECTED]
Date: Thursday, December 30, 2004 5:23 pm
Subject: IO::Socket::UNIX questions

 Hello list,
Hi Dave,
 
 I am working with UNIX Sockets and have some questions that I cant 
 seem to find answers to on the web.
It can be hard to find a good site on all IPC programming. Check out Network 
programing with Perl, by Lincoln Stein. 

perldoc perlipc is a good start.

 
 1: Are UNIX sockets bi-directional?
yes, SOCK_STREAM type
 
 2: If so, what is the proper way to 'setup' the connection? (will 
 post what I have below)
what you have looks correct, no need to specify Type [ SOCK_STREAM is default]. 
I think the problem you may have is in setting permissions on socket files. 
Does the child have access priveledge to write to that file ?? what is the 
UMASK or you server process ?? Post more code, and output along with debug 
print umask in your server code.


 
 3: Do UNIX sockets have less overhead than INET sockets?
That all depends, it can go both way's. UNIX sockets, is comunicatting through 
files. Faster way would be to communicate through pipe's.

HTH,
Mark G. 
 
 Here is what I have for the OO connections:
 
 Server:
 
 my $server = IO::Socket::UNIX-new(Local = /tmp/mysock,
   Type  = SOCK_DGRAM,
   Listen= 5 )
  or die $@;
 
 Client:
 
 my $client = IO::Socket::UNIX-new (
   Type  = SOCK_DGRAM,
   Peer  = /tmp/mysock,
   )
 or die $@;
 
 Right now, I am able to send information from the client to the 
 server, but not the other way around. When I try this, I get:send: 
 
 Cannot determine peer address at server.pl line 21
 
 Here are lines 17-22:
 
  if($text ne 'exit')
  {
print \nReceived message ', $text,'\n;
my $send = I got: $text\n;
$server-send($send,128);# --- Line 21
  }
 
 I have tried multiple things with the creation of the socket, but 
 cant get the right combination. I am beginning to think that UNIX 
 sockets are not bi-directional, but I hope someone proves me wrong.
 
 If more information is needed, let me know.
 
 Thanks for the help,
 
 Dave Kettmann
 NetLogic
 636-561-0680
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: IO::Socket - i can't get it to read the data

2004-10-17 Thread Peter Scott
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jeff 'japhy' Pinyan) writes:
The problem is that your data ends in \r\n, and the \r is a carriage
return.  If you print jeff\rABC, you'd *see* ABCf, because the \r
causes the cursor to go to the beginning of the line, thus overwriting
previous letters.  In your case, apparently the IP address is longer than
both the username and the password, so the IP is all you're seeing.

And just so the original poster knows *why* they're getting a \r,
the reason is that the standard for line-oriented socket protocols
is to terminate lines with \r\n.  At least, what \r\n is on Unix-type
systems (\015\012); Perl changes the value of \n on some other platforms.
This is why Socket.pm exports upon request the symbol $CRLF, which is
the proper line terminator regardless.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: IO::Socket - i can't get it to read the data

2004-10-15 Thread Etienne Ledoux
ok it seems like the chomp it stuffin it up ?
if i removed it i get the correct data but with a \n



On Friday 15 October 2004 11:56, Etienne Ledoux wrote:
 greetings,

 This program listens on a port for an incoming connection. Once someone
 connected it asks for a name and a password. but for some reason  I can't
 get it to read the name/password entered. what am i missing please...

 while (($client,$client_address) = $server-accept()) {

 # Get the client ip
 ($client_port, $c_ip) = sockaddr_in($client_address);
 $clientip = inet_ntoa($c_ip);

 print $client \nname\n;
 chomp ($cl_name = $client);
 print $client pass\n;
 chomp ($cl_pass = $client);
 print $client \n$cl_name $cl_pass $clientip\n;

 }

 e.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: IO::Socket - i can't get it to read the data

2004-10-15 Thread Etienne Ledoux
Would anybody have any idea why chomp is deleting the value ?

No matter how I try and do it. I even tried s/\n//,$value . afterwards I have 
a empty value. I don't understand what I'm doing wrong here and everywhere i 
check this it seems to be the right way to do it.  ?!?!

e.

On Friday 15 October 2004 12:16, Etienne Ledoux wrote:
 ok it seems like the chomp it stuffin it up ?
 if i removed it i get the correct data but with a \n

 On Friday 15 October 2004 11:56, Etienne Ledoux wrote:
  greetings,
 
  This program listens on a port for an incoming connection. Once someone
  connected it asks for a name and a password. but for some reason  I can't
  get it to read the name/password entered. what am i missing please...
 
  while (($client,$client_address) = $server-accept()) {
 
  # Get the client ip
  ($client_port, $c_ip) = sockaddr_in($client_address);
  $clientip = inet_ntoa($c_ip);
 
  print $client \nname\n;
  chomp ($cl_name = $client);
  print $client pass\n;
  chomp ($cl_pass = $client);
  print $client \n$cl_name $cl_pass $clientip\n;
 
  }
 
  e.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: IO::Socket - i can't get it to read the data

2004-10-15 Thread Jeff 'japhy' Pinyan
On Oct 15, Etienne Ledoux said:

Would anybody have any idea why chomp is deleting the value ?

No matter how I try and do it. I even tried s/\n//,$value . afterwards I have
a empty value. I don't understand what I'm doing wrong here and everywhere i
check this it seems to be the right way to do it.  ?!?!

The problem is that your data ends in \r\n, and the \r is a carriage
return.  If you print jeff\rABC, you'd *see* ABCf, because the \r
causes the cursor to go to the beginning of the line, thus overwriting
previous letters.  In your case, apparently the IP address is longer than
both the username and the password, so the IP is all you're seeing.

  ($user = $client) =~ s/\r?\n$//;
  ($pass = $client) =~ s/\r?\n$//;

That should work for you.

-- 
Jeff japhy Pinyan %  How can we ever be the sold short or
RPI Acacia Brother #734 %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %-- Meister Eckhart


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: IO::Socket for http download

2004-07-02 Thread Ramprasad A Padmanabhan

 LWP requires none of those tools. It does exactly what you are 
 describing: it opens a socket and uses the HTTP protocol to talk to the 
 server.
 
 Randy.
 

Right. Do you have any sample http client script , using IO::Socket
If I get some sample script , my work will be reduced a lot 


Thanks
Ram



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: IO::Socket for http download

2004-07-02 Thread Randy W. Sims
Ramprasad A Padmanabhan wrote:
I want to write a basic http download ( text/binary) script using
IO::Socket. Does anyone have any examples anywhere.
I know ,everyone must be wondering why I cant use ready modules like
LWP.
Well I want to auto transfer files to different remote machines. and
these machines ( in all flavors of unix/linux ) dont have tools like
LWP/ftp/wget/lynx etc and I cant install these on the machines
LWP requires none of those tools. It does exactly what you are 
describing: it opens a socket and uses the HTTP protocol to talk to the 
server.

Randy.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: IO::Socket for http download

2004-07-02 Thread Ramprasad A Padmanabhan
On Thu, 2004-07-01 at 18:24, Ramprasad A Padmanabhan wrote:
 I want to write a basic http download ( text/binary) script using
 IO::Socket. Does anyone have any examples anywhere.


Thanks all,
I found a basic and excellent example. ( It pays to be patient when
using google)
http://perl.active-venture.com/pod/perlipc-tcpclient.html

Thanks
Ram



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: IO::Socket problem how to receive data?

2002-09-02 Thread Felix Geerinckx

on Sun, 01 Sep 2002 15:15:27 GMT, [EMAIL PROTECTED] (Anthony) wrote:

 I'm trying to learn IO::Socket and i have a little problem is that
 i DO NOT know how to receive data i use the recv function but
 doesn't work at all. 

[...]

 But I can send data to a perl program but I don't know how to
 translate it. 

Have you already checked out

perldoc perlipc

(especially the section on 'TCP Servers with IO::Socket')?

-- 
felix

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: IO::Socket problem how to receive data?

2002-09-02 Thread James Edward Gray II

I'm not sure I totally understand all of your question, but talking over 
an IO::Socket is pretty darn simple, if we're talking about a line 
oriented protocol.  You can use what you have always used for Perl input 
and output:

use IO::Socket::INET;
my $socket = IO::Socket::INET-new( PeerAddr= $server,
  PeerPort  = 
$port, )
or die Socket Error:  Unable to connect to host.;
# and then simply...
print $socket $line to send\n;  # send a line
my $line_read = $socket;  # read a line

I'm not sure exactly what you meant by translating the data, but a 
common socket problem in that the talking program and the listening 
program are expecting different line endings, because of the platform 
they're running on.  UNIX systems use Line Feed (\012) as a line ending, 
Mac applications favor the Carriage Return (\015) though many Mac OS X 
programs are switching over to UNIX thinking, and Windows is usually 
looking for a Carriage Return followed by a Line Feed (\015\012).  Many 
networking protocols, including telnet, take the Windows road and look 
for both characters.  In that case, we have to change my above example a 
little:

use IO::Socket::INET (:DEFAULT :crlf);  # import a shortcut for both 
characters
local $/ = CRLF;  # sets reads to terminate after seeing both characters
my $socket = IO::Socket::INET-new( PeerAddr= $server,
  PeerPort  = 
$port, )
or die Socket Error:  Unable to connect to host.;
print $socket $line to send, CRLF;  # we now end our lines with both 
characters
my $line_read = $socket;  # works because of the variable change above

Well, I hope that helps.  If I missed your problem, take another stab at 
explaining what's going wrong and I'll try again.  Good luck.

James

On Monday, September 2, 2002, at 09:09  AM, Felix Geerinckx wrote:

 Hi,

 I'm trying to learn IO::Socket and i have a little problem is that i DO 
 NOT
 know how to receive data i use the recv function but doesn't work at 
 all.

 I know how to send data- I know it works because it is a visual basic
 program that receives the data and it displays the correct data.

 But I can send data to a perl program but I don't know how to translate 
 it.

 Any HELP is REALLY appreciated.

 Anthony


James


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: IO::Socket problem how to receive data?

2002-09-02 Thread anthony

Hi,


I've read the perl doc but it was not usefull any how i fixed it, what i was
trying to do is to send data from a Visual basic program to a perl program,
then from perl to a visual basic program

thanx anyways guys,
Anthony



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: IO::socket close() and bad file descriptor

2002-05-04 Thread Peter Scott

At 02:05 PM 5/3/02 -0400, Keddie, Diane wrote:
We are working on an application that makes a socket connection to our
mainframe to get information.  The code we use for the socket connection is
as follows:
[snip]
my $close=close($sock);

The socket connection works, and we get the appropriate information back
from our mainframe scripts.  However, the return value from close($sock) is
1 with Bad file number in $!.  Should we be concerned that the socket
connection is not closing properly and could cause other problems?

$ perldoc -f close
close FILEHANDLE
close   Closes the file or pipe associated with the file
handle, returning true only if stdio successfully
flushes buffers and closes the system file
descriptor.

You got a true result.  The connection closed properly.  The value of $! is 
irrelevant.

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: IO::socket close() and bad file descriptor

2002-05-04 Thread drieux


On Friday, May 3, 2002, at 11:05 , Keddie, Diane wrote:
[..]

 my $close=close($sock);

 The socket connection works, and we get the appropriate information back
 from our mainframe scripts.  However, the return value from close($sock) 
 is
 1 with Bad file number in $!.  Should we be concerned that the socket
 connection is not closing properly and could cause other problems?

 --Diane

wow - that is mostly sorta like an issue when you do the
variation of

netstat -naf inet | grep 99

do you find that the port on your host is in say a FIN_WAIT
state or any of that??? which can be annoying. So it could
be as simple as the file handle has been rudely closed by
the far end - or you have really skanked $sock inside of
your while loop - not as probable

What you may wish to do is use the shutdown() as a part of
both sides of the socket - so that they do the close of the
socket a bit more politely - and brief their respective kernels
that they are not planning to do any more BizNiz on this file
descriptor and hence to toss any kernel buffers associated
with the fd. what I did was wrap all of that in one place:

sub dtk_closeSocket {

 my ( $dtk_sock ) = @_;
 shutdown($dtk_sock,2);  # tell the other end we are outahere
 close($dtk_sock);
}

this way both sets of kernels are aware that we are not at all
interested in what they had left in any kernel buffers - so
I of course didn't think about what the return on the close
would be - because, well, I just clearly did not care one
way or the other.

I of course had already done the

 unless ( setsockopt($dtk_sock, SOL_SOCKET, SO_REUSEADDR,1) ) {
 die Unable to set socket\n;
 }

so that that we could close out on our side and reuse the port.

This of course lead to pushing that stuff into my first perl
library - before I 'got' perl modules.

since what you are doing seems so close to being the stock
uri schema - have you thought about getting the libwww-perl
and saving yourself some of the heart ache of doing
socket level management?

cf:

perldoc LWP::UserAgent




ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




last and labels was Re: IO::socket close() and bad file descriptor

2002-05-04 Thread drieux


On Saturday, May 4, 2002, at 08:19 , Peter Scott wrote:
[..]
 You got a true result.  The connection closed properly.  The value of $! 
 is irrelevant.

my complements.

my question is why the use of the while() construct in

http://www.perldebugged.com/downloads/proxylog.txt

hence the need to have the last LABEL construction???

especially as this appears to avoid the call to your
shutdown function - which seems to be doing an implicit
close based upon the exit.

which has me a tad concerned about the

$client-shutdown(2) if $client;
$server-shutdown(2) if $server;

since it would seem that the former would prevent the
full on closer of the server side

I may just be a bit too fussy here - but there are several
webSites I run into where they clearly are not doing
their socket connections correctly - as I get them
wedgied in the fin_wait state

So I thought I would ask for a bit of 'what was the
idea behind this approach' 


ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: last and labels was Re: IO::socket close() andbad file descriptor

2002-05-04 Thread Peter Scott

At 09:04 AM 5/4/02 -0700, drieux wrote:
my question is why the use of the while() construct in

 http://www.perldebugged.com/downloads/proxylog.txt

hence the need to have the last LABEL construction???

especially as this appears to avoid the call to your
shutdown function - which seems to be doing an implicit
close based upon the exit.

Correct.

which has me a tad concerned about the

$client-shutdown(2) if $client;
$server-shutdown(2) if $server;

since it would seem that the former would prevent the
full on closer of the server side

No, they both close okay, every time I've tried it, at least.  But the if 
$client/$server is unnecessary... vestigial from a paste from the signal 
handler.

I may just be a bit too fussy here - but there are several
webSites I run into where they clearly are not doing
their socket connections correctly - as I get them
wedgied in the fin_wait state

So I thought I would ask for a bit of 'what was the
idea behind this approach' 

Trying to make it as simple as possible.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: IO::Socket::Inet

2002-01-22 Thread Bob Showalter

 -Original Message-
 From: Jorge Goncalvez [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, January 22, 2002 11:42 AM
 To: [EMAIL PROTECTED]
 Subject: Re:IO::Socket::Inet
 
 
 Hi, i have this
 use IO::Socket;
 $port=21;
 
 $server=155.132.48.23;
 #$server=192.40.54.41;
 
 $sock = IO::Socket::INET-new(PeerAddr  =$server,
 PeerPort = $port,
 Proto = 'tcp') ;
 
  it works but what i wanted is to make it not from a remote 
 host but a local 
 host to avoid needing ip adress.
  i tried this:
  $sock = IO::Socket::INET-new(LocalHost  ='localhost',
 PeerPort = $port,
 Proto = 'tcp') ; 
   but it fails I don't know how to specify 'localhost'
   Thanks.  

If I understand correctly, the server process is running on
the local host. In that case, use:

   PeerAddr = 'localhost' 

instead of LocalHost = 'localhost'

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: IO::Socket

2001-09-13 Thread Newton, Philip

Veeraraju_Mareddi wrote:
 Dear List,

Which list? You sent this to two lists, as far as I can tell. In Usenet,
that would be the equivalent of crossposting, and then I consider it good
etiquette to set a Followup-To header directing answers to one group only.
Setting a Reply-To header here might have been appropriate as well, or only
selecting one list in the first place.

 Please update me any links towards creating  SCOKETs, Communicatin on
 sockets and Communication between processes using Socket communication

Update? What have you got at the moment?

At any rate, I suggest `perldoc perlipc` and the Perl Cookbook, which has
several examples on sockets.

 my script need to contact a process which is on remote machine.

Did you write the remote process yourself, or is it already there and you
have to interact with it? If the latter, consult its documentation, since
you'll have to play by its rules. If we say that method X is great for
inter-process communication is great, but the remote process doesn't support
method X, it's not going to be very helpful.

 Any documentation with Examples are Quite helpful..

See the Perl Cookbook, then.

Cheers,
Philip
-- 
Philip Newton [EMAIL PROTECTED]
All opinions are my own, not my employer's.
If you're not part of the solution, you're part of the precipitate.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: IO::Socket::INET cannot find despite existence

2001-06-06 Thread Ondrej Par

On Wednesday 06 June 2001 18:25, Craig Moynes/Markham/IBM wrote:
 So I fail to see the problem.  It seems to work if I change the use line
 to: use IO::Socket; but that is 'incorrect' or at the very least
 imprecise right ?




That's correct. With 'use', you are saying what should be the name of .pm 
file with module - and it's IO::Socket. Inside that file, there is defined 
package IO::Socket::INET (among other things). In short: package file name 
does not necessarily have to match package name.


-- 
Ondrej Par
Internet Securities
Software Engineer
e-mail: [EMAIL PROTECTED]
Phone: +420 2 222 543 45 ext. 112