hello!
D3 linux 10.3.4 on redhat 8.4
very simple code ( from the doc, but setsockopt is very poorly documented !)
'test.socket' size = 1086
cfunction socket.builtin
include dm,bp,includes sysid.inc
include dm,bp,unix.h socket.h
* Create a socket
listen.port=4062
buffer.size=1024
timeout=255
fd=%socket(af$inet, sock$stream, 0)
******* <- here !
ret=%setsockopt(fd,SOL$SOCKET,SO$RCVTIMEO, timeout,1)
print ret
* Bind the socket to a local Ethernet port.
* Use default address.
char buffer[buffer.size]
if %bind(fd, af$inet, inaddr$any, listen.port)<0 then
crt "bind failed"; stop
end
* Wait for incoming connection and allow up to
* three more to be waiting.
%listen(fd, 3)
* debug
* Accept a connection until got them all
loop
address=0; port=0
socket=%accept(fd, &address, &port)
until socket<0 do
crt "Called by address ":address:", port #":port
* Read data from the data link
%recv(socket, buffer, buffer.size)
* Done with this connection, close it
print trim(buffer)
char buffer[buffer.size] ; * re-init
%closesocket(socket)
repeat