Socket buffers

If you want to experiment with code for my earlier question about setsockopt and send buffer truncation, I’ve written a small test program (Linux based, might work on Mac too tho, shouldn’t be too hard to port to Winsock)

I haven’t had to look at sockets this way for a very long time, but now that I am, I’m remembering how bloody annoying the supposedly ultra-clean and simple BSD socket API is…

Sockets: data black holes.

Sometimes, the opacity of the BSD socket interface is a real pain in the backside.

For example, what happens if you do the following:

/* Set a 4k outgoing buffer size */
int bufSize = 8*1024 ;
setsockopt(socket, SOL_SOCKET, SO_SNDBUF,  &bufSize, sizeof(int)) ;
/* Send 8k of data to a host we know will only receive 2k for a while */
retval = send(socket, buffer, bufSize) ;
/* Data is now in the send buffer, but the remote host
only has buffers for 2k, so 6k of our buffer is "hot" */
int shortSize = 2*1024 ;
int retval = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, &shortSize, sizeof(int)) ;
/* Did we just truncate the outgoing send buffer? Or will this generate an error */

My fail failed :(

I failed to fail :(

Plugged the two NetGear Powerline AVs into wall sockets, connected one to my router downstairs, the other to my PC upstairs. Booted up the PC, BAM.

Working perfectly. I get a little under 92 million bits per second to/from my Laptop. Which is perfectly acceptable since I only have a 100Mb ethernet port on each.

Best of all, with one less wireless device in this already overcrowded wireless zone, my laptop’s wireless connectivity has doubled.

More fail in the works…

I have had zero luck with hardware lately: from the Laptop that doesn’t like to run Linux (Toshiba Satelite L505-GS5035), buying the Kindle days before the iPad launched, buying a Lexmark printer, a 32Gb SSD drive just before deciding I wanted to dual boot, etc, etc :)

So I decided to ride the curve :) I ordered a pair of NetGear powerline-network plugs to let me connect my computer room to the cable router without going over the wireless n, which I’d rather not use if I don’t have to – there are so many wireless networks here it’s hard to find a channel I get decent reception on :(