[Issue 7338] New: Non-blocking socket.accept() behavior differs on platforms

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 21 10:47:03 PST 2012


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

           Summary: Non-blocking socket.accept() behavior differs on
                    platforms
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: soul8o8 at gmail.com


--- Comment #0 from Heywood Floyd <soul8o8 at gmail.com> 2012-01-21 10:47:02 PST ---
// - - - - - 8< - - - - 
import    std.stdio, std.socket;
void main()
{
    auto lsock = new TcpSocket();
    lsock.blocking(false);
    lsock.bind(new InternetAddress("127.0.0.1",5000));
    try{
        lsock.listen(1);
    }catch(Exception e){
        writeln("listen() failed (This is not the bug, choose another port?)");
        return;
    }

    try{
        auto sock = lsock.accept();
        writeln("Accept returned: ",sock);
    }catch(Exception e){
        writeln("Accept threw Exception:\n",e);
    }

    lsock.close();
}
// - - - - - 8< - - - -

Behavior when socket.accept() is called when no new connection is available:

- Linux, OSX: An Exception is thrown
- Windows: A new Socket(isAlive=false) is returned
- Other: <untested>

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


More information about the Digitalmars-d-bugs mailing list