http://d.puremagic.com/issues/show_bug.cgi?id=5183

           Summary: WinSock error occurs when socket is created in thread
                    other than main
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: debio...@gmail.com


--- Comment #0 from Andrew Wiley <debio...@gmail.com> 2010-11-06 18:29:48 PDT 
---
I'm still investigating exactly what causes this, but here's a simple test case
to show what I'm talking about:
import std.stdio;
import std.socket;
import core.thread;

void main() {
    testSocket();
    auto t = new Thread(&testSocket);
    t.start();
}
shared ushort port = 5000;
public void testSocket() {
    try {
        auto socket = new TcpSocket();
        socket.bind(new InternetAddress("0.0.0.0", port++));

    }
    catch(SocketException e) {
        writefln("Error: %d", e.errorCode);
        return;
    }
    writefln("success!");
}


The output:
success!
Error: 10093

According to http://msdn.microsoft.com/en-us/library/ms740668(VS.85).aspx the
10093 code is WSANOTINITIALISED, which means the following:
Either the application has not called WSAStartup or WSAStartup failed. The
application may be accessing a socket that the current active task does not own
(that is, trying to share a socket between tasks), or WSACleanup has been
called too many times.

WSAStartup was definitely called because the first socket was created
successfully. I'm still figuring out how the second one fails.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to