Originally Posted By: Wims
So after closing the socket client-side, trying to send a packet to that client results in the server socket itself being closed, [..]

This is in fact intended WinSock behavior: if an ICMP "port unreachable" packet arrives for a UDP socket, this will produce an asynchronous WSAECONNRESET error on the UDP socket and close it. Terrible behavior as far as I'm concerned, but it's hard to blame mIRC for closely following WinSock behavior.

While recreating the socket after an error is possible, this will necessarily create a time window in which packets arriving from other hosts would be lost - this is true both when scripted and if mIRC were to do this natively. I think that the best solution would be to use the (relatively new) SIO_UDP_CONNRESET ioctl to disable the behavior on UDP sockets, either always or with a new "don't kill my socket on errors" /sockudp flag.

Edit: upon reading the documentation again, I'm no longer sure whether WinSock actually expects applications to close UDP sockets upon getting ECONNRESET as well. Could it be that the text "should close the socket" text applies to TCP sockets only, and mIRC is unnecessarily closing the UDP socket by incorrectly assuming the error is fatal to it, too? I can't easily test this, but the MSDN text is rather ambiguous I think..

Last edited by Sat; 28/06/17 11:31 PM.

Saturn, QuakeNet staff