I'm very new to the websocket, I'm trying to make a simple websocket server with c# from scratch, anyone have a simple sample?? that I can understand easily? Like just send string ("hello client") to the client side(HTML5 with JavaScript) I'm using google chrome, Thank you
- If you're building it from scratch for fun, then please pay no attention to me when I say that Websockets are a built-in feature of ASP.net 4.5. See here paulbatum.com/2011/09/getting-started-with-websockets-in.htmljessegavin– jessegavin2012-03-15 16:18:15 +00:00Commented Mar 15, 2012 at 16:18
- Is this different from your question yesterday?simonc– simonc2012-03-15 16:20:46 +00:00Commented Mar 15, 2012 at 16:20
- The question was to use websocket for file transfer, apparently it's really complicated, so I try to ask for a basic oneEldon Lesley– Eldon Lesley2012-03-16 07:36:28 +00:00Commented Mar 16, 2012 at 7:36
- Here is to make it clear, I would like to create a server with a basic functionality to send message/string to the client (in browser)Eldon Lesley– Eldon Lesley2012-03-16 07:57:40 +00:00Commented Mar 16, 2012 at 7:57
Add a comment |
3 Answers
I would recommend you Fleck - very easy to start with and clean.
4 Comments
weismat
There is a console app project which shows you the implementation of a chat echo server. Very simple to use. You need to implement delegates for OnOpen, OnClose, OnMessage and can use Send to send data.
Eldon Lesley
thanks! it worked! but I need to study the server first, since I need to modify it to send message to the client in string format (customizable)
Eldon Lesley
unfortunately though, I can't make a server from scratch, and this Fleck is a hell lot of complex code, and need some time to understand, but the usage is very simple
weismat
There is a byte array and a string method - so you should be flexibale in your format - adding another send method should be really trivial.
You may also take a look at the WebSocketRPC library, which is simple enough. Some code snippets are shown on the page.
Disclaimer: I am the author.