Unexpected behaviour on socket

Gythzel jrgurg at dsfiifa.uk
Tue Feb 9 08:07:47 PST 2010


(relating code at http://dpaste.com/156595/ on D2)

This is a very trimmed version of something I'm experimenting with, so the design of the code is not the issue. The problem is what happens on the "accepter" function.

After the Socket.select returns 1 (meaning, 1 socket has its state changed) I do a .receive on the only socket inside the set and that function returns 0 (meaning connection closed). However, I'm still able to send through that socket and the socketset keeps saying the socket is ready, although everytime I do a .recieve on it, 0 bytes are read. I used PuTTY to test this program (to open a connection) and even though I didn't close the connection the program keeps saying it was remotely closed (.receive==0). Also, isAlive() of this socket returns true.

Am I doing something wrong?

This program is similar to listener.d on the samples dir of the compiler, however, that sample works without a problem (after sorting D2 stuff on that file, see http://d.puremagic.com/issues/show_bug.cgi?id=2000).


More information about the Digitalmars-d-learn mailing list