Don't ask to ask, just ask | |
PerlMonks |
IO::Socket::UNIX close() discards data when called "too soon"?by ddzeko (Acolyte) |
on Jan 20, 2004 at 14:09 UTC ( [id://322586]=perlquestion: print w/replies, xml ) | Need Help?? |
ddzeko has asked for the wisdom of the Perl Monks concerning the following question: Hi Monks, I'm writing a daemon that will listen on UNIX socket, accept connections, take a request, crunch a bit on it, and spit out a response. A problem arises when server closes connection after writing out on socket what it had to say. Somehow the data gets lost and client never receives it. A kludge is to add sleep(1) just before the close. But, this is not acceptable in "production" application because it severely limits throughput to less than 1 msg/sec. Is there a way to make IO::Socket::UNIX do a REAL FLUSH on that UNIX socket so client could read the data that's been written to it? Here is the server's code:
And here is my sample UNIX socket client:
I've tried SO_LINGER stuff (snippet found on google/groups) in server...
But to no avail. PLEASE HELP!!™ :)
Damir Dzeko -- PGP keyID: 38ED4CFF
Back to
Seekers of Perl Wisdom
|
|