I am using this http://anismiles.wordpress.com/2011/02/03/websocket-support-in-android%E2%80%99s-phonegap-apps/#comment-689 plugin. I am experiencing a problem where when I create the websocket object and a regular tcp server written in c#. I confirm the the connection headers are recieved, however, the onopen or onmessage events in the javascript are not fired? Any suggestions? Thanks!
You mention using a regular tcp server. Are you aware that a websocket connection is slightly more complicated that a regular tcp connection? You have to complete a handshake then frame all subsequent messages. Your browser handles all this for you on the client; you have to provide equivalent code on the server.
RFC 6455 describes the protocol if you want to write your own server. Or you could use an existing C# server - using either the .NET v4.5 class or a third party server.
Related
Actually I'm using node.js and socket.io to establish a socket connection. For some reasons I need to replace the server part with an ASP.NET application. Therefore I have to replace the existing socket.IO-server with a suitable .NET pendant.
From my understanding socket.IO as well as SignalR use websockets. So can I replace the socket.io-server with a signalR-server without or with even minimal changes in the clients?
Actually I tried to setup a SignalR-Server using the following example http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-server
I'm able to connect to the hub when I use the sample code mentioned there.
But I'm not able to connect to this server using socket.IO or websockets in nodeJS. Maybe because of the magic with the hubs.
So is there any solution for an easy to use .NET package, hosted in IIS, that allows secured websocket-connections or secure tcp-socket connections between clients and my server. This solution should be quite standard so I can use Java or Node or anything else on client side?
I develop a some socket bridge between C# server and node.js client.
Firstly, I thought to use legacy TCP/IP socket, but on second thought websocket is way too easier in async style programming of node.
XSockets.NET looks good and clean, and I will use it as a websocket server.
I know ws is widely used for fundamental websocket layer for node, but we have socket.io or engine.io. I wonder if socket.io-client is a proper choice as a socket client, and want to double check what I miss.
Do you have any other option in this case?
Perhaps, any abstract layer is not needed, and I should use only ws..
Thanks!
If you are using XSockets.NET as a server you can connect any socket to the server. You do not have to talk websockets. You can actually use the Node.JS socket to connect and send data.
The trick to do so is to implement a custom protocol. As long as you send JSON it is very simple. Just inherit create a new protocol from the protocol-template provided by XSockets.NET
These short demos might explain more in detail:
demo 1
demo 2
EDIT: If you are just getting started with the project I would recomend you to join the group that test XSockets.NET 4.0 The next gen of XSockets is much much improved over the 3.* versions. Just send a mail to contact#xsockets.net if you want in!
My client sends messages to the my server using tcp protocol (my server has a listener).
I'm trying to send messages back from the server to the client, but I'm not sure what do I need to add to the client in order to get those messages.
I tried looking it up, but I didn't understand how to implement it.
Could you please assist?
It's the exact same process, but in reverse.
If you intend to receive messages independently (i.e. not in response to a request by the client), you need to make the client a TCP server, too. The client needs to implement exactly the same thing as the server you have now and the server needs to connect to the client.
Can't you use WCF, which supports callback contracts?
If you want a console example of a client server application using a network library see here http://www.networkcomms.net/how-to-create-a-client-server-application-in-minutes/.
If you want a WPF application example then see here http://www.networkcomms.net/creating-a-wpf-chat-client-server-application/
I am doing applications on .net remoting ,i write the code for
Client -----------> server
but
client <------------ server
i don't know how to do it(just like a chat),Please give suggestions and some samples to look up.
without any request from server i send messages from my client application
Try using MarshalByRefObject and events. This would allow the Server to respond back to the client.
Here is a sample on code project
Another Sample with Event CallBack
My need is to communicate between 2 client behind NAT using http tunneling. Is it possible? What all setup is needed to achieve this (like http proxy server etc.)? Is there any library or sample code available for implementing http tunneling over TCP in C#?
It might be possible for you to use this library:
http://granados.sourceforge.net/
It supports port forwarding (tunneling in this case),
but I haven't tried it myself.
It's an SSH library... so if you can set up an SSH server on either end of the connection
you'll be able to establish an SSH connection and create a tunnel.