jgoz / crossroads-net

Crossroads I/O bindings for .NET and Mono
www.crossroads.io
Other
14 stars 2 forks source link

Non-blocking Socket.Send (a bit too non-blocking) #5

Closed mszubart closed 11 years ago

mszubart commented 12 years ago

I've got my copy of crossroads-net from github (cloned) so it is the latest version. I'm using libxs 1.2.0; .NET 4.5; Win7 x64 (but all libs are 32bit) My problem is:

sock.Send(data, data.Length, SocketFlags.None);

What should happen (and does in C/C++): This expression should block current thread and wait until data is received by another socket.

What is really happening:

Console.Write("A");
sock.Send(data, data.Length, SocketFlags.None);
Console.Write("B");

If server (socket receiving data) is not running, it prints 'AB' and exits. If I add something like 'wait key' and then run server, data is being received.

It would be nice to have blocking version of Socket.Send.

Thank you. And I apologize for my English.

edwinchenloo commented 11 years ago

There are no guarantees as to when the receiver gets or processes data being sent to it.

Is the question/concern to make Send() block until the bytes have been delivered to the network stack?

mszubart commented 11 years ago

After 4 months I barely remember what I meant but I remember that different language bindings worked in a different ways (c++ version was blocking, java not).

Crossroads doc says:

A successful invocation of xs_send() does not indicate that the message has been transmitted to the network, only that it has been queued on the socket and Crossroads have assumed responsibility for the message.

Let's stick to this.