IO::Socket: buffering error ?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


It seems i've a problem with socket-buffering ; i use IO::Socket::INET
to connect a client-program to a server-program, and send orders.

Every connection to the server is well-detected, but every string i
send to the server arrives *only* when i close the client-socket.

I've tried the flush and autoflush method, but result is the same.

Anyone would have an idea ?

Re: IO::Socket: buffering error ?

Quoted text here. Click to load it

Sounds like you have a flushing problem.

Quoted text here. Click to load it

Maybe you did it wrong.

Quoted text here. Click to load it

My idea would be make a small complete program which demonstrates the
problem, and show the damn thing to the people you are asking for help.
Maybe that is just me.


-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB

Re: IO::Socket: buffering error ?

You'll find the both client and server program here: /


Re: IO::Socket: buffering error ?

Well, please learn how to quote properly. I know Google is not the best
newsreader you could use, but I've heard there is an option to quote as
recommended. Please, read something about quoting in newsgroups, eg at

It would be in *your* interest to provide some context when composing
contributions to a newsgroup. In the following, I fixed this for you.

* galdor schrieb:
Quoted text here. Click to load it

Well, your server is reading the messages line by line. But how to know
the length of a line? Right, simply add a CRLF ("\r\n") to the rear of
the messages. I prefer to use IO::Socket's capabilities for this (you've
to change the use-statement for IO::Socket::INET for that):

    use IO::Socket::INET qw( SOCK_STREAM CRLF );
    print $sock_com $comres, CRLF;
With that, your server reads the messages when they arrived instead of
reading them when the socket is closed. The CRLF means as much as "this
is the end of this message".

Btw, I suggest to turn on autoflush for STDOUT by writing

in the beginning of your script (well, this could be a particularity of
my console on WinXP, but without that I don't see anything on my screen
before the script terminates -- your console's behavior could differ).

Quoted text here. Click to load it

That is not exactly what Xho meant by asking for a "small complete
program". Indeed, they are complete programs, but "small" means to
remove all unnecessary parts of your scripts. Shortening a script is
what *you* should do in order that *we* don't have to search for the
relevant parts in your script.


Re: IO::Socket: buffering error ?

Fabian Pilkowski a écrit :
Quoted text here. Click to load it
Understood :)

Quoted text here. Click to load it
Fine trick, it's all good, !

Quoted text here. Click to load it
Ok, understood too.

Thank's for your help !


Site Timeline