HaB has asked for the
wisdom of the Perl Monks concerning the following question:

Hrm...

I have been poking at this one all morning, and I can't seem to figure this one out. I have a little server app that recieves data from a corresponding client app. The problem is, the server can't seem to figure out when the client is thru sending data. The spec on the project is that the server close and regenerate the socket after each client is finished sending data, but it never happens. The client sends, and the server just sits. I have tried every method/module I can think of. Here is the latest incarnation using IO::Select.

Caveat: This is under Win32, which I am new to developing under. Not sure if that matters or not.

select() tells you that at least one byte (or end of
file) is available to be read from a client.
<$client> will block at least until it
sees a newline or end-of-file. So there are lots of
ways for your server to hang for at least a while. You
may need to make your server more sophisticated.

So your code is expecting multiple lines (terminated by standard newlines) and is then splitting each "line" into different segments delimited by \r's ? That just seems weird. Be sure that $/ is what you expect it to be (so that <$client> works). If you need this to be more of a binary type of protocol, consider using sysread directly, read your data in binary chunks, and *then* split on your delimiter (making sure to keep the trailing bit around for the next time you read data, in case you get a partial command).

>> The spec on the project is that the server close and regenerate the socket after each client is finished sending data, but it never happens. The client sends, and the server just sits.

The problem is that the in the while(<$client>) loop the server keeps on processing until EOF is recived from the client.
However from your definition the client sends data, and then waits for the connection to be closed (which won't happen until it sends EOF).
If the client were to close the connection after sending the server would stop trying to read from the client.
Otherwise you need to send a specific prearranged EOF marker (specific character or string that won't occur in the data part of the transmission).

When putting a smiley right before a closing parenthesis, do you:

Use two parentheses: (Like this: :) )
Use one parenthesis: (Like this: :)
Reverse direction of the smiley: (Like this: (: )
Use angle/square brackets instead of parentheses
Use C-style commenting to set the smiley off from the closing parenthesis
Make the smiley a dunce: (:>
I disapprove of emoticons
Other