www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2835] New: std.socket.TcpSocket.accept blocks forever

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835

           Summary: std.socket.TcpSocket.accept blocks forever
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: graham.stjack internode.on.net


The attached code works in 2.0.26 and blocks on accept in 2.0.27


-- 
Apr 14 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835






Created an attachment (id=322)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=322&action=view)
Test case


-- 
Apr 14 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835


unknown simplemachines.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |unknown simplemachines.org
            Summary|std.socket.TcpSocket.accept |std.socket.TcpSocket.connect
                   |blocks forever              |doesn't actually connect





Just a drive-by.  Simplified testcase:

---
import std.socket, std.stdio;

void main()
{
        // Replace 12345 with any unused port.
        auto address = new InternetAddress("127.0.0.1", 12345);

        try
        {
                auto client = new TcpSocket();
                client.connect(address);

                writefln("Where's my error?");
        }
        catch (SocketException)
                writefln("Success");
}
---

Testcase succeeds on Windows, but not Linux, using 2.028 and CentOS 5.3.  Most
likely, incorrect size of the sockaddr_in struct or something.

-[Unknown]


-- 
Apr 15 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835






Created an attachment (id=324)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=324&action=view)
Set sin_family properly.

Pruning down some C-style socket code, I determined that sin_family was the
deciding factor on this behavior.  Unfortunately, it is unclear to me why this
would've regressed from 2.026 (since sin_family has never been set?)

Graham, you can work around this issue and verify the fix by recompiling phobos
or by writing a subclass for InternetAddress, e.g.:

---
import std.c.linux.socket, core.sys.posix.sys.socket;
import std.socket;

class MyInternetAddress: InternetAddress
{
        this(string addr, ushort port)
        {
                sin.sin_family = AddressFamily.INET;
                super(addr, port);
        }

        this(uint addr, ushort port)
        {
                sin.sin_family = AddressFamily.INET;
                super(addr, port);
        }

        this(ushort port)
        {
                sin.sin_family = AddressFamily.INET;
                super(port);
        }
}
---

If you could verify this fixes your issue, it would be appreciated.

Thanks,
-[Unknown]


-- 
Apr 15 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835






It did indeed fix the issue. My (improved) test code now works in 2.026 and
2.028 when I use the workaround.


-- 
Apr 16 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835


Foy Savas <foysavas gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |foysavas gmail.com



I can confirm this patch applying cleanly to the latest Phobos. Can we get this
in for the next DMD release? It's no exaggeration to say that working sockets
to some are both their bread and butter.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 24 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835


iorlas <denis.tomilin gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |4ybaka gmail.com



*** Issue 3649 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 05 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835




---
Created an attachment (id=567)
patch for std.socket

Patch for std.socket

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835


Shin Fujishiro <rsinfu gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



---
Fixed in svn r1543.
Thanks for the patches!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835


Sohgo Takeuchi <sohgo sohgo.dyndns.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sohgo sohgo.dyndns.org



PDT ---
Phobos1 has the same problem.
I am happy that this fix will be applied to the phobos1 too.
Thanks.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835




22:28:02 PDT ---
I have looked at the Changeset 1548.
Thanks for applying this fix to the phobos1.

BTW, Issue 3489 is also a same report of this issue I think.
So you can close the Issue 3489 too.

Thank you.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2835




---

 BTW, Issue 3489 is also a same report of this issue I think.
 So you can close the Issue 3489 too.
I see. Thank you for pointing it out to me. :D -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 23 2010