Network issue

L

Lepi

Hello

Please help...

I want to program a little client that sends something to a server, but
also reads an answer. What part of this code needs to be changed???

Also, is there a way to make a bidirectional communication, so if the
other side has something to say, my client can accept it without sending
a request??? How can I do that??

Thanks

use IO::Socket;
$adr=IO::Socket::INET->new(
Proto=>'tcp',
PeerAddr=>'localhost',
PeerPort=>'2332'
)
or die "Not good";

print("Input > ");
$in=<STDIN>;
print $adr $in;
 
R

Rhesa Rozendaal

Lepi said:
Hello

Please help...

I want to program a little client that sends something to a server, but
also reads an answer. What part of this code needs to be changed???

Also, is there a way to make a bidirectional communication, so if the
other side has something to say, my client can accept it without sending
a request??? How can I do that??

Sockets are bidirectional.
Thanks

use IO::Socket;
$adr=IO::Socket::INET->new(
Proto=>'tcp',
PeerAddr=>'localhost',
PeerPort=>'2332'
)
or die "Not good";

print("Input > ");
$in=<STDIN>;
print $adr $in;

$output = <$adr>;
or
$output = $adr->readline();
etc.

Suggested reading:

perldoc IO::Socket::INET
perldoc perlipc
perldoc IO::Socket
perldoc Socket

Rhesa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top