in reply to Slow sockets

Why are you always reading byte by byte from the socket? $len is always 1. If you receive multiple data sets, then you might need to cache the leftovers from the previous read. I did this also once when starting with sockets and saw then the huge speed improvement. One issue is that on multiple platforms different read sizes are recommend, but I would recommend you to use a len of at least 1024.

Replies are listed 'Best First'.
Re^2: Slow sockets
by Bagarre (Sexton) on Oct 31, 2007 at 16:02 UTC

    I can bump the read up to a bigger size but that doesnt seem to be the issue for now.

    I just added $out_handle->flush(); after writing to it and everything is fast again. Looks like syswrite was being buffered somehow.

    Sorry for the hacked code. The module does a few things more than seen here which is why some of it doesnt make sense. Like the bless and returning nothing. I ripped out the portions that I thought were causing the issue and stuck them here.

    So, $out_handle->flush(); speeds everything up but I dont understand why syswrite($out_handle, $REQUEST, length($REQUEST); would be buffered.

    Entities should not be multiplied unnecessarily.