in reply to Read Socket on Server

You are not checking the result of the sysread. To do so could be enlightening...

Replies are listed 'Best First'.
Re^2: Read Socket on Server
by ipentinmaki (Initiate) on Sep 29, 2008 at 22:19 UTC
    It contains the length of the message. In this case 62 on each read.
    The full program does the if defined, if rc>0 and $!==EWOULDBLOCK for a non-blocking socket.
    Speaking of non-blocking I am testing on WinXP. Is it another aberration of windows and I should switch to testing on unix (which is where the client will be).
      Do you actually get the output you describe from the posted version or only the non-blocking version? Something is seriously messed up to get the behaviour you described from the code you posted. It makes more sense for the non-blocking version since you never clear $data.

      Update: To clarify, by "you never clear $data", I mean you rely on sysread to clear $data, and it's entirely reasonable to fit to not do so when it detects there's nothing to read.

        Your right I made an assumption about sysread clearing the data in the example.
        Clearing $data and $rc inbetween had no effect.
        Yes, both the blocking short example and the non-blocking full version are behaving the same way on windows as the sysread result is greater than zero.
        I checked the simple client and larger version on HP-UX with the same behavior. I also added enough code to the example to send an ack back so I don't think it is a resend.