How to receive data from a socket

S

Suk

Hi

Im new to perl socket programming.

I have a server program on a certain machine which simply cat's a file
when it receives a connection to port 10000 . This is done via inetd on
a Solaris system as follows:

Line in /etc/inetd.conf:

# Test program
test stream tcp nowait root /usr/bin/test1

Line from /etc/services:

# Test program on port 10000
test 10001/tcp

The script /usr/bin/test1 simply contains a single line to cat a
certain text file, so if you telnet to port 10000 you simply get the
contents of the file.

I want to write a very simple perl script to connect to this server and
receive the data into $data
Problem is that the contents of the file can be very large (>300K) and
i dont seem to be getting all the data into $data

Im doing something like this:

our $sock = new IO::Socket::INET ( PeerAddr => $MESSAGE_SERVER,
PeerPort => $TARGET_PORT, Proto => 'tcp',);

And then receiving the data like this:

recv($sock,$data,3000,0);

$data doesnt contain everything though.


Like I say, i've never really done any socket programming before, so if
if someone knows the correct way of receiving data then that woulbe be
appreciated.
 

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,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top