Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Thanks mattk
In fact I am using fork() on Windows (my bad). However, my problem reduces to something like this:
My server:
use IO::Socket; use IO::Select; my $socket= new IO::Socket::INET ( LocalHost => 'localhost', LocalPort => 9000, Proto => 'tcp', Listen => SOMAXCONN, Reuse => 1); if (not defined $socket) { die "no server"; } my $sel= IO::Select->new($socket); print "Waiting for connections on port 9000\n"; my @ready; my $client; my $message; my $new; while (@ready= $sel->can_read) { foreach $client (@ready) { #client speaking if ($client == $socket) { #new client -> add client print "new client\n"; my $add= $client->accept; $sel->add($add); print "added\n"; } else { #old client print "old client \n"; $client->recv($message,256); print $client."\n"; $client->send($client); $client->recv($new, 256); print $new."\n"; $new->send("ok"); } } }

My client:
my $sock; my $message; my $socket= new IO::Socket::INET ( PeerHost => 'localhost', PeerPort => 9000, Proto => 'tcp'); if (not defined $socket) { die "no server"; } $socket->send("something"); $socket->recv($sock, 256); $socket->send($sock); $socket->recv($message, 256);
And this gives me something like:
Waiting for connections on port 9000 new client added old client IO::Socket::INET=GLOB(0x1b19628) IO::Socket::INET=GLOB(0x1b19628) Can't locate object method "send" via package "IO::Socket::INET=GLOB(0x1b19628)" (perhaps you forgot to load "IO:Socket::INET=GLOB(0x1b19628)"?) at server.pl line 39

In reply to Re^2: IO::Socket::INET file handler by Razvanica
in thread IO::Socket::INET file handler by Razvanica

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-03-29 02:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found