in reply to Multiple clients with IO::Sockets, IO::Select

  1. The next section in the book says that the filehandle blocks, but I don't understand this. Can someone restate it for me?

    A blocking socket is where the read() function does not return control to your program until data arrives. A non-blocking read() will cause the read() to return to you, but with no data.
  2. While I'm expecting to trust my clients, I can see problems if one gets stuck in an infinite loop and sends me continuous data...how would I stop that? Particularly if I'm trying to read all the info the client sends before acting on it.

    Your code will have to make a determine it a client is talking too much. If they are, you could first try sending a command down the pipe to shut-up and restart. Or, more drastically, you can just close the socket, and the client will fall off.
  3. This code has an infinite loop, which is obviously incompatible with a GUI. I'd like to make this a package that can be used by different UIs. I have an idea of how to do this (put the loop into subroutine, make it for a limited time rather than infinite, ditto with the select, and call it via a timed event in the calling program), but any advice on pitfalls to avoid would be appreciated.

    Every system I've ever worked on is event driven, and has a mechanism either for your program to call their handler (like the Net::IRC module), or for you to hook your code in, where you get called on a regular basis (Windows). Some do this with timer events, some make a pass through their own event lists, and then call yours, so until an event happens, you both get about 1/2 of the processes available time.
  4. Because the clients will also be modules that can be GUI based, they'll probably be polling the server to check for status changes. Assuming the clients all sent a did-anything-change query once a second, would the above code allow everyone to get talked to, or would one client have priority over the others?

    I have to defer this one. Perhaps someone else will have a more definitive answer.
  5. This all sounds like its creating some significant network traffic...is this normal? I may just be nervous since I'm used to the mostly non-interactive web.

    This is very dependant on how *much* data you'll be sending, and over what kind of transport. 2K per second over a 33.6K modem is a fairly high rate. On a T1, it starts to be more in the noise. There are ways to determine the loading factors, and perhaps you could be dynamic. You may also find that you don't need to poll once a second, that every 5 seconds will be sufficient. But since the nature of your data isn't indicated, it's hard to make an accurate assesment.


--Chris

e-mail jcwren
  • Comment on (jcwren) Multiple clients with IO::Sockets, IO::Select