A couple of months ago I started creating a socket wrapper to make creating socket connections a little easier. Yesterday, I started working on it again and came across a 'bug' when setting the ReceiveBufferSize. I wanted to make the SendBufferSize and ReceiveBufferSize changeble by the user. Here is the code:
// Set these socket optionsthis.tcpClient.SendBufferSize = this.sendBufferSize;this.tcpClient.ReceiveBufferSize = this.receiveBufferSize;
The error returned when setting ReceiveBufferSize was "An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call"
Upon further investigation (and with help from Sandeep P.) by searching getsockopt and setsockopt from the error message I came accross this:
Note This option is only supported for SOCK_DGRAM sockets.
So, basically Windows CE only supports setting the ReceiveBufferSize if you are using Datagrams (or UDP) and since I'm using TCP .NETCF throws the error. It's not really an bug, but something not supported by the underlying OS (Windows CE) which VS.NET2005 IDE let's you see using IntelliSense. Don't get me wrong IntelliSense has been greatly improved for Compact Framework (see here) and TCPClient.ReceiveBufferSize I'm sure is rarely used.
So if you're doing some socket programming on a device be aware of this. 8K of buffer size should be big enough, but just be aware of this when using TCPClient.
Note: On the desktop setting ReceiveBufferSize does not throw an exception.
Powered by: newtelligence dasBlog 1.9.7174.0
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
E-mail
Theme design by Jelle Druyts