[VPM] socket problem. please help. it's driving me crazy!

Peter Scott Peter at PSDT.com
Sat Jan 10 11:58:58 CST 2004


At 09:01 PM 1/9/2004 -0800, Darren Duncan wrote:
>At 7:49 PM -0800 1/9/04, Jeremy Aiyadurai wrote:
> >I am wondering if someone can help me with a socket problem.
> >I can get windows box to talk to a windows box and linux box to talk 
> to a linux box.
> >I am trying to get a linux box and windows box to talk to each other.
> >But it just wont work, the scripts just stall. I know they connect, 
> but they wont talk.
> >I dont know what I am doing wrong.
> >Your help will be appreciated.
> >Thanks in advance.
> >Jeremy A.
> >Here is the code for the client and server
>
>Without running the code, what I can suggest given what you said did 
>and didn't work is that there may be a line termination issue.

I agree.  The code uses "\n", which means something different on 
Windows and Unix.  This is why the standard Socket module exports the 
constant $CRLF, network standard as you say below.

There are also higher-level modules for facilitating client-server 
apps.  A CPAN search should turn up something better than just printing 
to sockets.  If the application desires asynchronicity, I would look at POE.

>Unix and Windows naturally have different characters for ending 
>lines.  Your server is reading into $data until it reaches a 
>linebreak, which will never come because the client sends something 
>different than the server expects.  That is, unless IO::Socket::INET 
>translates these for you (I doubt it).
>
>I suggest strategic use of code like this on both server and client 
>(its network standard linebreaks I think):
>
>         my $endl = "\015\012";  # cr + lf
>         local $\ = $endl.$endl;
>         local $/ = $endl.$endl;
>
>I use that myself in my CGI::Portable::AdapterSocket module.
>
>Another suggestion is to look at what IP address the server and client 
>thinks it is.  If the client is trying to talk to a server that is 
>ignoring it, but the server exists, what would happen?
>
>-- Darren Duncan

-- 
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/
*** New! *** http://www.perlmedic.com/




More information about the Victoria-pm mailing list