tcp server

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi There,

I have written a little tcp server to send out some GPS data stream
from a text to a client, the code looks something like this:

while (1) {
      print "GPSsim: sending data to PRG \n";
      open (my $handle, '<', $filename) or die "Can't open '$filename'
for reading: $!";

      foreach $line (<$handle>) {
        print $client "<IsiPut><GPRMC>".$line."</GPRMC></
        #print "<IsiPut><GPRMC>".$line."</GPRMC></
        if (!<$client>) {
          print "GPSsim: CLIENT DISCONNECTED - exit!\n";

now my problem is that <$client> sometimes seem to become false and
thus my program exits even tho the client is still there and
listening! How does this happen and how can i overcome this problem so
i can put (<$client>) in the while instead of (1). I realize that this
is dirty, please do not comment on this.... :P

Thank you for hints and suggestions!


Re: tcp server

cerr wrote:
Quoted text here. Click to load it

use strict;
use warnings;

Quoted text here. Click to load it
for my $line ( <$handle> ) {
Quoted text here. Click to load it

Why include commented out lines in your post?  It's just more noise..

Quoted text here. Click to load it

First, you do understand what <$client> does, right?

Quoted text here. Click to load it

You don't show what $client or $sock is, post actual code! However,
before doing that, the document to study would be:

perldoc perlipc

There is a lot of good information in there and maybe the area with the
"TCP Servers with IO::Socket" heading might help with this specific

Re: tcp server

On Fri, 10 Sep 2010 11:37:45 -0700, cerr wrote:

Quoted text here. Click to load it

Did you read the posting guidelines? There is so much missing in your
program, your question is impossible to answer. Construct a minimal
program that exhibits the problem and post that.


Site Timeline