C# WebSocket WebSocket4Net Demo code

10 篇文章 0 订阅

WebSocket4Net

a .NET websocket client implementation.

It originated from SuperWebSocket WebSocket Client. For better developing of the websocket client, it was separated from SuperWebSocket and was renamed to WebSocket4Net.

WebSocket4Net will provide websocket client implementation for many different kinds of runtime:

  • .Net 2.0
  • .Net 3.5
  • .Net 4.0
  • Mono
  • Silverlight
  • WindowsPhone
  • Mono for Android
  • MonoTouch (New)

 

  Mono Windows Phone

 

It is compatible with many websocket drafts:

  • Hybi-00
  • Hybi-10
  • RFC6455

 

NuGet Packagehttp://www.nuget.org/packages/WebSocket4Net

Demo code:  

 

using WebSocket4Net;
 
WebSocket websocket = new WebSocket("ws://localhost:2012/");
websocket.Opened += new EventHandler(websocket_Opened);
websocket.Error += new EventHandler<ErrorEventArgs>(websocket_Error);
websocket.Closed += new EventHandler(websocket_Closed);
websocket.MessageReceived += new EventHandler(websocket_MessageReceived);
websocket.Open();

private void websocket_Opened(object sender, EventArgs e)
{
     websocket.Send("Hello World!");
}

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值