jomonantony has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks
I am using the following code for getting request from the clients. I want to know where the requests from the clients are stored? is it in an array? if it, how can I get that array? Please help me.

#tcpserver.pl #Developed: Jomon C Antony 28-05-2010 #Purpos: To imploment Snail Mail use IO::Socket; use vars qw($dbh %GLOBS $INVOICE $PRINTER $q); $| = 1; require "snail.conf"; $socket = new IO::Socket::INET ( #LocalHost => '127.0.0.1', LocalHost => '192.168.25.77', LocalPort => '5000', Proto => 'tcp', Listen => 5, Reuse => 1 ); die "Coudn't open socket" unless $socket; print "\nTCPServer Waiting for client on port 5000"; while(1) { $client_socket = ""; $client_socket = $socket->accept(); $peer_address = $client_socket->peerhost(); $peer_port = $client_socket->peerport(); print "\n I got a connection from ( $peer_address , $peer_port ) " +; while (1) { $client_socket->recv($recieved_data,1024); print "\n RECIEVED: $recieved_data"; if($recieved_data eq "Client SnailMail") { `download.pl`; } print "completed."; close $client_socket; last; } }

Replies are listed 'Best First'.
Re: Where TCP server stores the client requests?
by jethro (Monsignor) on Jun 28, 2010 at 11:15 UTC

    The data is in $received_data. But only the first line. The intention seems to be that further reading on the socket should be delegated to another script called download.pl, although I don't know how the open socket is propagated to the script.

Re: Where TCP server stores the client requests?
by Anonymous Monk on Jun 28, 2010 at 12:15 UTC
    You've been here a little while now, this was your 9th post.

    How do I post a question effectively?
    XY Problems are boring. For you as the poster, its often a slow process getting the information you need. If you provide the whole picture people will be able to guide and assist you much better...

    1. What is download.pl meant to do?
    2. If download.pl failed, would you know about it?Or would the error be silently ignored...
    3. What do you mean I want to know where the requests from the clients are stored? is it in an array? if it, how can I get that array?
    - Why does that matter, your script only processes client connections one at a time...?
    - What sort of work do you need to do with the request information?
    - What information do you specifically need access to?
    4. The phrase please help me without a well written question reeks of lack of effort in trying to find the solution to this problem yourself... The monastery monks are not here to do your work or homework for you. Its here to help all those that want to learn to learn. Period.
Re: Where TCP server stores the client requests?
by Anonymous Monk on Jun 28, 2010 at 10:45 UTC