Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communicating with a socket.io server via c#

Is there a c# client that follows the socket.io protocol? I have a socket.io server that is communicating with a socket.io javascript client via a website, but i also need to connect a c# piece to it that can send and receive messages. Is there a clean way to do this currently or will I have to write my own client.

like image 983
Dested Avatar asked Jun 27 '11 22:06

Dested


People also ask

How do I connect to a Socket.IO server?

listen(port); // Create a Socket.IO instance, passing it our server var socket = io. listen(server); // Add a connect listener socket. on('connection', function(client){ console. log('Connection to client established'); // Success!

Is Socket.IO TCP connection?

The Socket.IO library keeps an open TCP connection to the server, which may result in a high battery drain for your users.

Does Socket.IO need HTTP?

Websocket is created when you make upgrade from http to websocket, so it kind of does need http. socket.io isn't a pure Websocket server/implementation, it depends on HTTP for its initial connection setup.


1 Answers

There is a project on codeplex ( NuGet as well ) that is a C# client for socket.io. (I am the author of this project - so I'm biased) I couldn't find exactly what I needed in a client, so I built it and released it back into the open.

Example client style:

socket.On("news", (data) =>    { Console.WriteLine(data); }); 
like image 53
Jim Stott Avatar answered Oct 05 '22 00:10

Jim Stott