Ask a Question related to PERL Miscellaneous, Design and Development.
-
Harshavardhan #1
Socket troubles
Hi,
I am trying to create two sender and listener sockets using perl.
***************
Listener.pl
***************
#! /usr/bin/perl
use IO::Socket;
$sock = new IO::Socket::INET ( LocalHost => 'localhost',
Local Port => 1200,
Proto = 'tcp',
Listen = 5,
Reuse = 1);
die "Socket could not be created. Reason: $!" unless $sock;
while ( $new_sock = $sock->accept() ) {
while (defined ($buf = <$sock>)) {
print $buf;
}
}
close ($sock)
***********************
Sender.pl
***********************
#! /usr/bin/perl
use IO::Socket;
$sock = new IO::Socket::INET ( PeerAddr => 'localhost',
PeerPort => 1200,
Proto = 'tcp',
);
die "Socket could not be created. Reason: $!" unless $sock;
foreach (1 .. 10) {
print $sock "Msg $_: How are you? \n";
}
close ($sock)
***********************
When run the Listener, it waits for new connections, but when I run the
sender.pl, it just finishes without any output at the listener. I get no
error messages.
Any ideas on whats happening?
Thanks
harsha
when I run hostname on my computer, it returns localhost.localdomain. I am
running both the sender and the listener on my computer. I am using Perl
5.8.0
Harshavardhan Guest
-
MS-SQL troubles
I have a user who needs access to my SQL server. He can ping the server, but he cannot setup an ODBC connection. I am using SQL authentication and I... -
FTP Troubles
If you are using version 2002 it does not default to index. Versions 2002 and 2003 name the home page according to what you enter for a file name... -
Socket.accept problem via Socket.for_fd($stdin.fileno)
Hi, I am experiencing a rather infuriating problem with Socket.accept on Windows XP. The problem exists when I try to create a Socket from... -
Distinguishing between socket buffer full & socket disconnected
I am using the IO::Select method can_write() to flow control the writing of a large amount of data to a socket, where the writer may well run ahead... -
css troubles
Pardon my ignorance.... I'm really new at this stuff. I'm trying to take some text on my webpage (I didn't create it... someone else did in DMX... -
Mina Naguib #2
Re: Socket troubles
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Harshavardhan wrote:^^^^^^^^^^> Hi,
>
> I am trying to create two sender and listener sockets using perl.
>
> ***************
> Listener.pl
> ***************
>
> #! /usr/bin/perl
>
> use IO::Socket;
> $sock = new IO::Socket::INET ( LocalHost => 'localhost',
> Local Port => 1200,
This is not syntatically-correct code
^^^> Proto = 'tcp',
This is an illegal modification of a constant, again not syntatically-correct.
^^^> Listen = 5,
So is this one.
^^^> Reuse = 1);
And this one.
Do NOT re-type Perl code when posting to usenet. Use copy+paste or your newsreader's "import" function.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - [url]http://enigmail.mozdev.org[/url]
iD8DBQE/Z8HIeS99pGMif6wRAkyeAJ9y5BH/bSkOAmCuVBwdvH5qG/jkygCglxck
wYUhYEqCrcMkrmL/InDLI6o=
=E+CH
-----END PGP SIGNATURE-----
Mina Naguib Guest
-
mooseshoes #3
Re: Socket troubles
I hate to sound like everyone else in this newsgroup, but if you're not
using
use strict;
use warnings;
you will be developing in the dark.
Best of luck,
Moose
mooseshoes Guest
-
Harshavardhan #4
Re: Socket troubles
Thanks guys.
After I used
use strict;
use warnings;
and after specifying each variable with its package name I found out the
error and now my program is working. Next time I post I will remember to
cut and paste the code.
Thanks for all your help
harsha
"mooseshoes" <mooseshoes@gmx.net> wrote in message
news:fyR9b.90$qm2.55@newssvr27.news.prodigy.com...> I hate to sound like everyone else in this newsgroup, but if you're not
> using
>
> use strict;
> use warnings;
>
>
> you will be developing in the dark.
>
> Best of luck,
>
> Moose
Harshavardhan Guest
-
Uri Guttman #5
Re: Socket troubles
>>>>> "H" == Harshavardhan <hvardhan@ee.duke.edu> writes:
H> After I used
H> use strict;
H> use warnings;
H> and after specifying each variable with its package name I found out the
H> error and now my program is working. Next time I post I will remember to
H> cut and paste the code.
first off, don't top post.
secondly, that is the wrong way to work with strict. the correct way is
to use my. what you did is create package globals and that is not good
practice.
uri
--
Uri Guttman ------ [email]uri@stemsystems.com[/email] -------- [url]http://www.stemsystems.com[/url]
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- [url]http://jobs.perl.org[/url]
Damian Conway Class in Boston - Sept 2003 -- [url]http://www.stemsystems.com/class[/url]
Uri Guttman Guest



Reply With Quote

