hxcpp icon indicating copy to clipboard operation
hxcpp copied to clipboard

Make socket poll select function error informative

Open codeservice opened this issue 5 years ago • 0 comments

On windows 64 bit I have random issue when some sockets become not valid. Error 10038. I didn't see this on Win 32 or other platforms yet. It's good to have at least error message when it happens.

For haxe server it can be used as work around fix:

	function loopThread( t : ThreadInfos ) {
		if( t.socks.length > 0 ) {
            var available: Array<Socket> = null;
            try {
                available = t.p.poll( t.socks, connectLag );
            }catch(e: Dynamic){
                trace(e); //process error 10038 here
                while(t.socks.length>0) {//stop all thread sockets
                    var s: Socket = t.socks.pop();
                    var infos : ClientInfos<Client> = s.custom;
                    try s.shutdown(true,true) catch( e : Dynamic ) {};
                    doClientDisconnected( s , infos.client );
                }
                return;
            }

Error info: (https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2) WSAENOTSOCK 10038 Socket operation on nonsocket. An operation was attempted on something that is not a socket. Either the socket handle parameter did not reference a valid socket, or for select, a member of an fd_set was not valid.

codeservice avatar Aug 14 '19 19:08 codeservice