develooper Front page | perl.beginners | Postings from January 2002

RE: Access Transmitted Data On "Server" Side Of A TCP Socket

Thread Previous | Thread Next
Hewlett Pickens
January 31, 2002 14:36
RE: Access Transmitted Data On "Server" Side Of A TCP Socket
Message ID:
I apologize for the multiple posts.  The post with attachments was
"rejected" once by the list with "Your mail to murzc could not be delivered
because murzc is not accepting mail with attachments or embedded images" so
I sent it a second time with the code snippets included in the post.  Don't
know how the "attachment" version got in a second time though.

Thank you all for the replies, but so far no luck.  I 

>> print "$client\n";  #ADD THIS JUST FOR KICKS, SEE WHAT YAH GET
   It gave me what I think is packed socket data:

>>  shouldn't you have Proto    => "tcp", in the IO:::Socket... on server as
well as client?  
   It wasn't in the book's example so put it in, but made no difference.
Since the client receives data from the server, I think the TCP setup is

I also changed  

   my $dataIn = $client->recv($bufferIn, $bufferSize);

   my $dataIn = $server->recv($bufferIn, $bufferSize);

Now I don't get the junk characters but nothing prints out.  To see if it
came from the "recv", added this initialization line prior to the "recv" to
see if something overlaid it. The print command printed nothing, so
"something" was placed into the buffer.

   my $dataIn = "Set up by me before doing the recv"; 

Looked at the "recv" function in
/usr/lib/perl5/5.00503/s390-linux/IO/Socket.p and to my untrained eye, it
looks like I'm providing the correct arguments. "$flags" will be set to 0
since I don't provide it.

sub recv {                                                                
    @_ == 3 || @_ == 4 or croak 'usage: $fh->recv(BUF, LEN [, FLAGS])';   
    my $sock  = $_[0];                                                    
    my $len   = $_[2];                                                    
    my $flags = $_[3] || 0;                                               
    # remember who we recv'd from                                         
    ${*$sock}{'io_socket_peername'} = recv($sock, $_[1]='', $len, $flags);

Hewlett M. Pickens
B I Moyle Associates, Inc.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About