JoeJaz has asked for the wisdom of the Perl Monks concerning the following question:
The next bit of code is the recieving portion of the socket code (server)#!/usr/bin/perl use strict; use IO::Socket; my $sock = new IO::Socket::INET ( PeerAddr => '10.2.7.193', PeerPort => '7788', Proto => 'tcp', ); die "Could not create socket :-( $!\n" unless $sock; print $sock "hello world!"; close($sock);
When I execute the recieving program on the server machine and then execute the sending program on the cliant machine, I would expect that the cliant would send the text "hello world" to the server machine. I, however, am recieving the following error message instead:#!/usr/bin/perl -w use strict; use IO::Socket; my $sock = new IO::Socket::INET ( LocalHost => '10.2.7.193', LocalPort => '7788', Proto => 'tcp', Listen => 2, Reuse => 1, ); die "Could not create socket: $!\n" unless $sock; my $new_sock = $sock->accept(); while(defined(<$new_sock>)) { my $storage = $_; print $storage; } close($sock);
I am new to socket programming, but do realize that is very powerful. If anyone has any ideas of what might be wrong or any resources that might help me out, I would be very appreciative of your help. Thank you for your time in looking at my problem. Have a nice day :-)Use of uninitialized value in print at ./socket_serv line 17, <GEN1> l +ine 1.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Sockets Problem
by cbro (Pilgrim) on Jul 07, 2003 at 21:40 UTC | |
by JoeJaz (Monk) on Jul 10, 2003 at 15:57 UTC | |
|
Re: Perl Sockets Problem
by tcf22 (Priest) on Jul 07, 2003 at 21:38 UTC | |
by JoeJaz (Monk) on Jul 10, 2003 at 16:06 UTC |