digitalmars.D.learn - Unexpected behaviour on socket
- Gythzel (5/5) Feb 09 2010 (relating code at http://dpaste.com/156595/ on D2)
- Daniel Murphy (3/12) Feb 09 2010 The buffer you are passing to receive is 0 bytes long. The std.socket.S...
(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).
Feb 09 2010
Gythzel Wrote:(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).The buffer you are passing to receive is 0 bytes long. The std.socket.Socket.receive function is a wrapper over the normal socket function, and includes a test for an empty buffer. Daniel
Feb 09 2010
The buffer you are passing to receive is 0 bytes long. The std.socket.Socket.receive function is a wrapper over the normal socket function, and includes a test for an empty buffer. DanielOhh, I see. Thank you! I thought that the function would resize the buffer accordingly. Thank you for the clarification, i feel like an idiot *giggle*
Feb 10 2010
On 10.02.2010 14:41, daoryn wrote:http://d.puremagic.com/issues/show_bug.cgi?id=3794 Filed a bug.The buffer you are passing to receive is 0 bytes long. The std.socket.Socket.receive function is a wrapper over the normal socket function, and includes a test for an empty buffer. DanielOhh, I see. Thank you! I thought that the function would resize the buffer accordingly. Thank you for the clarification, i feel like an idiot *giggle*
Feb 11 2010