资源简介
Socket通信含服务端、客户端、WebSocket,代码完整清晰
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using StriveEngine.Core;
using StriveEngine.Tcp.Passive;
namespace StriveEngine.SimpleDemoClient
{
/*
* 更多实用组件请访问 www.oraycn.com 或 QQ:168757008。
*
* ESframework 强悍的通信框架、P2P框架、群集平台。OMCS 简单易用的网络语音视频框架。MFile 语音视频录制组件。StriveEngine 轻量级的通信引擎。
*/
public partial class Form1 : Form
{
private ITcpPassiveEngine tcpPassiveEngine;
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender EventArgs e)
{
try
{
//初始化并启动客户端引擎(TCP、文本协议)
this.tcpPassiveEngine = NetworkEngineFactory.CreateTextTcpPassiveEngine(this.textBox_IP.Text int.Parse(this.textBox_port.Text) new DefaultTextContractHelper(“\0“));
this.tcpPassiveEngine.MessageReceived += new CbDelegate(tcpPassiveEngine_MessageReceived);
this.tcpPassiveEngine.AutoReconnect = true;//启动掉线自动重连
this.tcpPassiveEngine.ConnectionInterrupted += new CbDelegate(tcpPassiveEngine_ConnectionInterrupted);
this.tcpPassiveEngine.ConnectionRebuildSucceed += new CbDelegate(tcpPassiveEngine_ConnectionRebuildSucceed);
this.tcpPassiveEngine.Initialize();
this.button2.Enabled = true;
this.button3.Enabled = false;
MessageBox.Show(“连接成功!“);
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}
void tcpPassiveEngine_ConnectionRebuildSucceed()
{
if (this.InvokeRequired)
{
this.BeginInvoke(new CbDelegate(this.tcpPassiveEngine_ConnectionRebuildSucceed));
}
else
{
this.button2.Enabled = true;
MessageBox.Show(“重连成功。“);
}
}
void tcpPassiveEngine_ConnectionInterrupted()
{
if (this.InvokeRequired)
{
this.BeginInvoke(new CbDelegate(this.tcpPassiveEngine_ConnectionInterrupted));
}
else
{
this.button2.Enabled = false;
MessageBox.Show(“您已经掉线。“);
}
}
void tcpPassiveEngine_MessageReceived(System.Net.IPEndPoint serverIPE byte[] bMsg)
{
string msg = System.Text.Encoding.UTF8.GetString(bMsg); //消息使用UTF-8编码
msg = msg.Substring(0 msg.Length - 1); //将结束标记“\0“剔除
this.ShowMessage(msg);
}
private void ShowMessage(string msg)
{
if (this.InvokeRequired)
{
this.Begi
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 518 2017-11-10 17:38 StriveEngine.SimpleDemo\Demo说明.txt
文件 323584 2018-12-11 11:21 StriveEngine.SimpleDemo\Resources\StriveEngine.dll
文件 70200 2018-12-11 11:21 StriveEngine.SimpleDemo\Resources\StriveEngine.xm
文件 2626 2016-07-06 10:09 StriveEngine.SimpleDemo\StriveEngine.SimpleDemo.sln
..A..H. 59904 2018-12-11 11:23 StriveEngine.SimpleDemo\StriveEngine.SimpleDemo.suo
文件 323584 2018-12-11 11:21 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\bin\Debug\StriveEngine.dll
文件 13312 2018-12-11 11:23 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\bin\Debug\StriveEngine.SimpleDemoClient.exe
文件 32256 2018-12-11 11:23 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\bin\Debug\StriveEngine.SimpleDemoClient.pdb
文件 11608 2018-06-01 13:24 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\bin\Debug\StriveEngine.SimpleDemoClient.vshost.exe
文件 490 2010-03-17 22:39 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\bin\Debug\StriveEngine.SimpleDemoClient.vshost.exe.manifest
文件 70200 2018-12-11 11:21 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\bin\Debug\StriveEngine.xm
文件 3884 2017-11-01 16:57 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\Form1.cs
文件 9312 2013-06-02 10:45 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\Form1.Designer.cs
文件 5817 2013-06-02 10:45 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\Form1.resx
文件 5562 2018-12-11 11:23 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 1774 2014-10-31 15:11 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\ResGen.read.1.tlog
文件 2098 2014-10-31 15:11 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\ResGen.write.1.tlog
文件 998 2013-06-02 10:31 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\StriveEngine.SimpleDemo.csproj.FileListAbsolute.txt
文件 26112 2013-06-02 10:30 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\StriveEngine.SimpleDemo.pdb
文件 180 2013-06-01 11:35 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\StriveEngine.SimpleDemo.Properties.Resources.resources
文件 17114 2018-12-11 11:23 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\StriveEngine.SimpleDemoClient.csproj.FileListAbsolute.txt
文件 975 2018-06-01 12:57 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\StriveEngine.SimpleDemoClient.csproj.GenerateResource.Cache
文件 10406 2018-12-11 11:23 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\StriveEngine.SimpleDemoClient.csprojResolveAssemblyReference.cache
文件 13312 2018-12-11 11:23 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\StriveEngine.SimpleDemoClient.exe
文件 180 2018-12-11 11:23 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\StriveEngine.SimpleDemoClient.Form1.resources
文件 32256 2018-12-11 11:23 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\StriveEngine.SimpleDemoClient.pdb
文件 180 2018-12-11 11:23 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\StriveEngine.SimpleDemoClient.Properties.Resources.resources
文件 4608 2013-06-02 10:36 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 643 2014-10-31 15:11 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\Program.cs
文件 1408 2013-06-02 10:42 StriveEngine.SimpleDemo\StriveEngine.SimpleDemoClient\Properties\AssemblyInfo.cs
............此处省略55个文件信息
- 上一篇:C#.NET编程与S7-200_PLC自由口通信
- 下一篇:CefSharp 57
相关资源
- C# 调用win32 api函数-user32.dll详细说明
- C# 调用BarTender打印条码DEMO
- 大型比赛竞赛抽签系统 可打印 c# vs
- C#编写的Gerber查看器
- lua C# .Net4.0 vs2010 LuaInterface
- C#十六进制编辑器
- 明华URF-35H读卡器 C#读写源码 为大家
- C#文件流读取CSV文件
- c#读写PDF文件sql
- C# winform Socket大文件传输
- c#车牌识别系统附30张测试图片
- 《C#面向对象程序设计》源代码(CS)
- 金旭亮《C#面向对象程序设计》教案
- 试题库管理系统毕业论文(C#)源程序
- 学校网站原代码(C#.NET)
- C#-数据库操作技术-员工管理系统
- c#web开发入门经典
- C#与Matlab混合编程的几种方式
- c# 开发与 mysql数据库实现的增删改查
- C#异步操作 异步查询数据库 异步处理
- Basler相机通过IO触发源码
- [源代码] 《领域驱动设计 (C# 2008 实
- 松下PLC与C#通讯串口调试入门教程.z
- USB 继电器控制器 LCUS-1 保证能用 c#
- C# AES加密解密小工具
- C#圆形按钮,非常漂亮动态~~
- [精]C#仿QQ右下角弹出提示框()
- C#进程间通信-共享内存代码
- 有史以来最简单的三层(C#)
- vb调用c#编写的串口DLL文件(vb源码
评论
共有 条评论