diff options
author | Benny Prijono <bennylp@teluu.com> | 2011-01-21 07:15:22 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2011-01-21 07:15:22 +0000 |
commit | 655354a2fb0081171025ed3dcd934193c11473c3 (patch) | |
tree | b4735de106f2d3c2d47184508b455c6e4297a433 /pjlib/src/pj/sock_bsd.c | |
parent | af600af2db9959eec72c28545df14e43d309099f (diff) |
Fixed #1197: WSAECONNRESET errors on Windows 2000 or 2003 may cause UDP transport to stop working
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3408 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/sock_bsd.c')
-rw-r--r-- | pjlib/src/pj/sock_bsd.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c index aef2ff8a..47e3fd14 100644 --- a/pjlib/src/pj/sock_bsd.c +++ b/pjlib/src/pj/sock_bsd.c @@ -493,8 +493,34 @@ PJ_DEF(pj_status_t) pj_sock_socket(int af, if (*sock == PJ_INVALID_SOCKET) return PJ_RETURN_OS_ERROR(pj_get_native_netos_error()); - else - return PJ_SUCCESS; + +#if PJ_SOCK_DISABLE_WSAECONNRESET && \ + (!defined(PJ_WIN32_WINCE) || PJ_WIN32_WINCE==0) + +#ifndef SIO_UDP_CONNRESET + #define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12) +#endif + + /* Disable WSAECONNRESET for UDP. + * See https://trac.pjsip.org/repos/ticket/1197 + */ + if (type==PJ_SOCK_DGRAM) { + DWORD dwBytesReturned = 0; + BOOL bNewBehavior = FALSE; + DWORD rc; + + rc = WSAIoctl(*sock, SIO_UDP_CONNRESET, + &bNewBehavior, sizeof(bNewBehavior), + NULL, 0, &dwBytesReturned, + NULL, NULL); + + if (rc==SOCKET_ERROR) { + // Ignored.. + } + } +#endif + + return PJ_SUCCESS; } #else |