The soConfigSet function sets a socket option.
The available options are:
option
|
data type
|
description
|
_SO_OPTION_BROADCAST
|
BOOL
|
Configure the socket to allow sending data to a broadcast address. (_SO_PROT_UDP only)
|
_SO_OPTION_KEEPALIVE
|
BOOL
|
Enable sending keep-alive messages in the socket (_SO_PROT_TCP only)
|
_SO_OPTION_LINGER
|
soOptionLinger
|
Configure the linger time in the socket. (_SO_PROT_TCP only)
|
Input:
socket : SYSHANDLE
Handle to the socket.
option : INT
The option to set.
data : PTR
A pointer to a buffer where the option data is stored.
Returns: INT
1
|
- Success.
|
0
|
- The function is not supported.
|
-1
|
- The handle is not a valid socket.
|
-2
|
- One or more parameters are illegal.
|
-3
|
- The socket is closed.
|
-5
|
- The socket does not support this action.
|
-17
|
- Generic error.
|
Declaration:
FUNCTION soConfigSet : INT;
VAR_INPUT
socket : SYSHANDLE;
option : INT;
data : PTR;
END_VAR;
Example:
INCLUDE rtcu.inc
PROGRAM example;
VAR
handle : SYSHANDLE;
val : soOptionLinger;
rc : INT;
END_VAR;
BEGIN
...
val.enable := ON;
val.linger := 10;
rc := soConfigSet(
socket := handle,
option := _SO_OPTION_LINGER,
data := ADDR(val)
);
DebugFmt(message := "soConfigGet=\1", v1 := rc);
...
END;
END_PROGRAM;
|