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

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

Thread Previous | Thread Next
From:
Hewlett Pickens
Date:
January 31, 2002 14:36
Subject:
RE: Access Transmitted Data On "Server" Side Of A TCP Socket
Message ID:
99FD2A07ACECD411942E0040AA44B190137209@bimsrv03.bimoyle.com
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:
IO::Socket::INET=GLOB(0x588f9c)

>>  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
working.

I also changed  

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

to
   
   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);
}                                                                         
           
                                                               
Hew

Hewlett M. Pickens
B I Moyle Associates, Inc.

  



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About