Message57504
| Author |
theller |
| Recipients |
christian.heimes, gvanrossum, nnorwitz, roudkerk, theller |
| Date |
2007年11月14日.19:28:59 |
| SpamBayes Score |
0.06693364 |
| Marked as misclassified |
No |
| Message-id |
<473B4C77.3020309@ctypes.org> |
| In-reply-to |
<1195065905.59.0.853545113036.issue1378@psf.upfronthosting.co.za> |
| Content |
Christian Heimes schrieb:
> Neal, Thomas, what do you think about the patch? Your knowledge of the
> Windows API is greater than mine. Is the duplicate_socket() function ok?
> I don't want to apply a patch I don't fully understand.
>
> +#ifdef MS_WINDOWS
> +/* On Windows a socket is really a handle not an fd */
> +static SOCKET
> +duplicate_socket(SOCKET handle)
> +{
> + HANDLE newhandle;
> +
> + if (!DuplicateHandle(GetCurrentProcess(), (HANDLE)handle,
> + GetCurrentProcess(), &newhandle,
> + 0, FALSE, DUPLICATE_SAME_ACCESS))
> + {
> + WSASetLastError(WSAEBADF);
> + return INVALID_SOCKET;
> + }
> + return (SOCKET)newhandle;
> +}
> +#define dup(fd) duplicate_socket(fd)
> +#define SOCKETCLOSE closesocket
> +#define NO_MAKEFILE /* socket handles can't be treated like file handles */
> +#endif
Not much time, so only one comment:
Is it wise to call WSASetLastError(WSAEBADF) instead of calling GetLastError()?
Thomas |
|