Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 09, 2010 Unexpected behaviour on socket | ||||
---|---|---|---|---|
| ||||
(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). |
February 10, 2010 Re: Unexpected behaviour on socket | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gythzel | 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
|
February 10, 2010 Re: Unexpected behaviour on socket | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | >
> 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
Ohh, 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*
|
February 11, 2010 Re: Unexpected behaviour on socket | ||||
---|---|---|---|---|
| ||||
Posted in reply to daoryn | On 10.02.2010 14:41, daoryn wrote: >> >> 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 > > Ohh, 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* http://d.puremagic.com/issues/show_bug.cgi?id=3794 Filed a bug. |
Copyright © 1999-2021 by the D Language Foundation