Does mod_fsock.fsock_setblock work in non Windows platform?
Issue #60
resolved
Running in Linux, I could not find any way to make fsock_setblock make UDP receiving non-blocking.
Private
int socket;
string from_ip;
byte bytes[256];
int port;
int received_bytes;
End
Begin
fsock_init ( 0 );
socket = udpsock_open ();
// I have tried with fsock_setblock ( socket, 1 ) and fsock_setblock ( socket, 0 ) and fsock_setblock ( socket, -1 )
say ( "Result setblock: " + fsock_setblock ( socket, 1 ) );
fsock_bind ( socket, 11000 );
timer [0] = 0;
Loop
If ( timer[ 0 ] > 300 )
received_bytes = udpsock_recv ( socket,
&bytes,
3,
&from_ip,
&port );
say ( "Received: " + received_bytes );
say(bytes[0]);
say(bytes[1]);
say(bytes[2]);
If ( received_bytes > 0 )
// multiplayer_process_receive_frame ( &bytes );
End
timer[ 0 ] = 0;
End
Frame;
End
OnExit:
fsock_close(socket);
fsock_quit ();
End
Comments (5)
-
reporter -
reporter Desired behaviour is that the loop executes no matter whether data has actually been sent.
-
reporter I have not tried in any other platform than Linux, Kernel 4.4.9-300
-
reporter Perhaps makes more sense with the name of the function to have
flags = (ulVal != 0) ? (flags &~O_NONBLOCK) : (flags|O_NONBLOCK);
-
repo owner - changed status to resolved
Merged in dacucar/pixtudio-dacucar (pull request #2)
Fix
#60Non-blocking mode not working in Linux→ <<cset 6fa6a8ca2673>>
- Log in to comment
Modifying libsocket.c would let me achieve desired behaviour:
Is this a bug? Or am I doing something wrong?