we have to call the windows API setsockopt to change the buffersize of
socket.
After we set the size we have to call getsockopt.
The first thing is, that we want to get the buffersize.
We get 0 by returnvalue of the function but ls_value is empty.
When we want to use setsockopt we always get errors.
Can someone help?
Please it's very urgent!
Greetings
Christian Freund
//Instance variables:
UINT SO_SNDBUF = 1 /* send buffer size */
UINT SO_RCVBUF = 2 /* receive buffer size */
UINT SO_SNDLOWAT = 3 /* send low-water mark */
UINT SO_RCVLOWAT = 4 /* receive low-water mark */
UINT SO_SNDTIMEO = 5 /* send timeout */
UINT SO_RCVTIMEO = 6 /* receive timeout */
UINT SO_ERROR = 7 /* get error status and clear */
UINT SO_TYPE = 8 /* get socket type */
UINT SO_DEBUG = 1 /* turn on debugging info recording */
UINT SO_ACCEPTCONN = 2 /* socket has had listen() */
UINT SO_REUSEADDR = 4 /* allow local address reuse */
UINT SO_KEEPALIVE = 8 /* keep connections alive */
UINT SO_DONTROUTE = 16 /* just use interface addresses */
UINT SO_BROADCAST = 32 /* permit sending of broadcast msgs */
UINT SO_USELOOPBACK = 64 /* bypass hardware when possible */
UINT SO_LINGER = 128 /* linger on close if data present */
UINT SO_OOBINLINE = 256 /* leave received OOB data in line */
UINT SOL_SOCKET = 65535 /* options for socket level */
//My function declaration is:
Function integer getsockopt ( uint socket, long level, long optname, REF
string optval, REF long optlen) Library "ws2_32.dll"
Function integer setsockopt ( uint socket, long level, long optname, ref
long optval, long optlen) Library "ws2_32.dll"
// Function Call:
INTEGER li_error
LONG ll_size
ULONG lul_rtn
UINT lui_socket
STRING ls_value, ls_buffer
ls_value = space ( 100 )
ll_size = inv_sizeof.sizeof ( ls_value )
IF getsockopt(lui_socket, SOL_SOCKET, SO_RCVBUF,ref ls_value, ll_size) =
-1 THEN
IF li_error <> 0 THEN
rs_errmsg = space ( 200 )
li_error = WSAgetLastError ()
formatMessage ( FORMAT_MESSAGE_FROM_SYSTEM, 0, li_error, LANG_NEUTRAL,
REF rs_errmsg, 200, 0 )
Messagebox ( "", "Error~r~n" + rs_errmsg )
ELSE
Messagebox ( "", "OK~r~n" + ls_value )
END IF
The API definitiion is likely misleading you. The value returned in optval
is unlikely to be an actual string. Its datatype is driven by the options
you requested in the prior two arguments. For the options you have used
(SOL_SOCKET, SO_RCVBUF), the value returned is a C int (PB long). In older
days, the datatype of optval would have been defined as (void *). The
easiest way to support this type of calling convention is to define multiple
external function definitions to the same function (with different argument
types). Below is an example
Function int WSAEnumProtocols (ref int lpiProtocols, ref
str_wsaprotocol_info lpProtocolBuffer, ref ulong lpdwBufferLength) Library
"ws2_32.dll" alias for WSAEnumProtocolsA
Function int WSAEnumProtocols (ulong nullval, ref str_wsaprotocol_info
lpProtocolBuffer, ref ulong lpdwBufferLength) Library "ws2_32.dll" alias for
WSAEnumProtocolsA
Function int WSAEnumProtocols (ref int lpiProtocols[], ref
str_wsaprotocol_info lpProtocolBuffer, ref ulong lpdwBufferLength) Library
"ws2_32.dll" alias for WSAEnumProtocolsA
> ls_value = space ( 100 )
> ll_size = inv_sizeof.sizeof ( ls_value )
>
> IF getsockopt(lui_socket, SOL_SOCKET, SO_RCVBUF,ref ls_value, ll_size)
> = -1 THEN
>
> IF li_error <> 0 THEN
Why are you checking li_error when it hasn't been set. The value has no
meaning at this point.