From: "H. Peter Anvin" <hpa@zytor.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Johannes Sixt <J.Sixt@eudaptics.com>, git@vger.kernel.org
Subject: Re: MinGW port usable
Date: Fri, 02 Feb 2007 00:55:38 -0800 [thread overview]
Message-ID: <45C2FC8A.4060206@zytor.com> (raw)
In-Reply-To: <45C2F648.9030105@zytor.com>
H. Peter Anvin wrote:
> H. Peter Anvin wrote:
>>
>> Except they are (for NT-based Windows), so you're doing something
>> goofy. This is a widely used construct, so it can't be that broken.
>>
>
> Erf... I dug through this, and it seems that WriteFile only works on a
> socket if it has an OVERLAPPED argument now, because the socket is
> opened for overlapping I/O. This must be new behaviour in XP-SP2,
> because this definitely wasn't the case when I last played with this
> stuff back in 2003. The Internet is full of people using this
> technique, but I haven't found a way to get a socket which is *not*
> opened for overlapping I/O.
>
> How typical of Microsoft to break an incredibly powerful unified
> paradigm, sort-of repair it, and then break it again. There doesn't
> seem to be an obvious way to repair this, either, since MS DLLs won't
> let you override for example the write() function as called from inside
> the C runtime DLL.
>
> "Some people are just a total waste of carbon..."
>
**HAH***
I found a workaround after all. The trick is to use WSASocket() with a
last argument 0 instead of socket().
I feel dirty now...
#include <winsock2.h>
#include <fcntl.h>
#include <io.h>
#define socket(a,b,c) sane_socket(a,b,c)
int sane_socket(int domain, int type, int protocol)
{
SOCKET s;
int fd;
s = WSASocket(domain, type, protocol, NULL, 0, 0);
if (s == INVALID_SOCKET) {
/*
* WSAGetLastError() values seem to be mostly
* errno+10000; verify this or replace this with
* a switch statement...
*/
errno = WSAGetLastError() - 10000;
return -1;
}
fd = _open_osfhandle(s, 0);
if (fd < 0)
closesocket(s);
return fd;
}
prev parent reply other threads:[~2007-02-02 8:55 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-29 22:20 MinGW port usable Johannes Sixt
2007-01-29 22:35 ` Shawn O. Pearce
2007-01-29 23:11 ` Christian MICHON
2007-01-29 23:24 ` Shawn O. Pearce
2007-01-29 23:48 ` Christian MICHON
2007-01-30 7:59 ` Christian MICHON
2007-01-30 8:07 ` Christian MICHON
2007-01-30 10:16 ` Johannes Schindelin
2007-01-30 15:27 ` Shawn O. Pearce
2007-01-30 16:31 ` Johannes Sixt
2007-01-30 8:47 ` Johannes Sixt
2007-01-29 22:46 ` Linus Torvalds
2007-01-29 23:08 ` Christian MICHON
2007-01-30 10:08 ` Johannes Schindelin
2007-01-30 10:14 ` Christian MICHON
2007-01-30 8:45 ` Johannes Sixt
2007-01-30 14:35 ` Johannes Schindelin
2007-01-30 15:18 ` Shawn O. Pearce
2007-01-30 15:38 ` Johannes Schindelin
2007-01-30 15:56 ` Shawn O. Pearce
2007-01-30 16:12 ` Johannes Schindelin
2007-01-30 16:28 ` Shawn O. Pearce
2007-01-30 16:49 ` Johannes Schindelin
2007-01-30 0:50 ` Daniel Barkalow
2007-01-30 8:23 ` Johannes Sixt
2007-01-30 8:41 ` Andreas Ericsson
2007-01-30 10:07 ` Johannes Schindelin
2007-01-30 17:09 ` Daniel Barkalow
2007-01-30 17:36 ` Johannes Schindelin
2007-01-30 18:09 ` Daniel Barkalow
2007-01-30 20:20 ` Johannes Sixt
2007-01-30 5:53 ` Junio C Hamano
2007-02-01 6:35 ` H. Peter Anvin
2007-02-01 10:34 ` Johannes Sixt
2007-02-01 21:05 ` H. Peter Anvin
2007-02-02 8:28 ` H. Peter Anvin
2007-02-02 8:49 ` Davide Libenzi
2007-02-02 8:55 ` Johannes Sixt
2007-02-02 8:55 ` H. Peter Anvin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45C2FC8A.4060206@zytor.com \
--to=hpa@zytor.com \
--cc=J.Sixt@eudaptics.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).