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

Hello again all, I asked a question about making servers a while ago, and I'd like to thank all who replied :). I've now made one, but I am now having issues with blocking. I have it properly connecting in a select loop for multiple connections, but when I send a byte to one connection, it blocks, and will not finish until that one connection is done.

How can I get the server to read without blocking too long on a connection?
_______________________________________________

"Intelligence is a tool used achieve goals, however goals are not always chosen wisely..."

Replies are listed 'Best First'.
Re: More Server Questions
by Fastolfe (Vicar) on Nov 21, 2000 at 19:13 UTC
    If you want to stick with the select-loop monolithic model (a very noble goal, but very difficult if you don't already know how sockets work), you need to place the socket in a non-blocking mode, and basically do everything that stdio is doing for you (behind the scenes, blocking): input/output buffers, checking for time-out conditions, etc. Unfortunately I don't know of a module that provides these basic functions for you (which would make writing apps of this nature infinitely easier for the novice).
Re: More Server Questions
by merlyn (Sage) on Nov 21, 2000 at 17:43 UTC
    Either compute faster ({grin}) or fork to handle each request to get the problem into a separate thread.

    Without seeing code, it's hard to give specific advice.

    -- Randal L. Schwartz, Perl hacker

      Thanks :) I think I see the path I must take now. In that case, what is the best way to share information between these processes? I was using a select based server to do that, but I am actually more partial to the multiprocess method.

      What steps would I need to set up an apache style server, where I just hand off connections to each pre-spawned child process?
      _______________________________________________
      "Intelligence is a tool used achieve goals, however goals are not always chosen wisely..."