Has anyone got trySend to work ?

Aug 21, 2014 at 4:46 PM
Hi,

I'm trying to use SuperWebSocket.

I'm finding that when I use trySend for binary data, it returns true, but the other end never receives the data.
When I replace the trySend with a plain send, it works fine, except that it now has the potential to block when used on a low bandwidth connection.

What is the right way to use trySend ? Is there some runMessagePump or serviceSocket thing I will need to call to make it actually send the data out ?

Here's the snippet of code: (payload is a byte array with about 100 bytes)

//doesnt work:
bSent = wsSession.TrySend(payload, 0, payload.Length);
works:
wsSession.Send(payload, 0, payload.Length);

I'm trying this out on Windows 7, though, my final target is mono. I had originally the package from nuget, but I have now tried replacing the dlls from the binaries I just downloaded from the codeplex site. The trySend still does not work.

Any ideas will be appreciated.
Coordinator
Aug 21, 2014 at 5:45 PM
Which client are you using? And which API of it are you using?
Aug 21, 2014 at 5:52 PM
Oops.

Looks like when I downloaded the new version and replaced my earlier nuget versions with the downloaded version, I had not realized that the namespaces had changed.

I went ahead and changed the namespaces now and it seems to work. I have not yet tested with a low bandwidth condition where trySend will return false, but atleast now, when it returns true, the data is coming over to the other side.

Kerry, thank you for the fast response.
I was using the superwebsocket .net library from nuget as a client.
Coordinator
Aug 21, 2014 at 6:23 PM
Did you misunderstand something?

The SuperWebSocket is the websocket server not a client.
Aug 21, 2014 at 8:43 PM
I meant to say I'm using WebSocket4Net from nuget as a client for testing from windows. You are right. superwebsocket is the server code and not used in the client.

Ultimately, the server is going to be running on mono and the actual clients will be c++ clients using libwebsockets.

Anyway, it seems to be working now.

The one thing I've not been able to do is to send data larger than about 10k bytes without causing a protocol error on the server. I've not found a way to send larger packets with WebSocket4Net. It only seems to allow me to change the receive buffer size and not the send buffer size. So, for now, I've limited the frame size to about 9k bytes. I would have liked to have upto 64k.

But in any case, I'm glad to have your .net libraries to work with. Thank you so much for contributing to open source.