资源简介
Socket通信,通过异步,解决粘包问题

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TcpIpSocketServer;
namespace SocketClient
{
public partial class Client : Form
{
public Client()
{
InitializeComponent();
}
TcpClient tcpClient = null;
private void btnStart_Click(object sender EventArgs e)
{
tcpClient = new TcpClient(“E:\\“);
tcpClient.ConnectedServer += new NetEvent(tcpClient_ConnectedServer);
tcpClient.DisConnectedServer += new NetEvent(tcpClient_DisConnectedServer);
tcpClient.ReceivedDatagram += new NetEvent(tcpClient_ReceivedDatagram);
tcpClient.Connect(txtIp.Text.Trim().ToString() int.Parse(txtPort.Text.Trim()));
}
///
/// 接受事件
///
///
///
void tcpClient_ReceivedDatagram(object sender NetEventArgs e)
{
}
///
/// 服务器断开事件
///
///
///
void tcpClient_DisConnectedServer(object sender NetEventArgs e)
{
MessageBox.Show(e.Client.ToString());
}
///
/// 连接服务器成功事件
///
///
///
void tcpClient_ConnectedServer(object sender NetEventArgs e)
{
txtRecive.Text = “服务器连接成功,可和进行通信 “ + DateTime.Now;
}
private void button3_Click(object sender EventArgs e)
{
if (tcpClient != null && tcpClient.IsConnected)
{
tcpClient.Close();
}
}
private void btnSend_Click(object sender EventArgs e)
{
for (int i = 0; i < 100; i++)
{
try
{
byte _class = (byte)‘A‘;
tcpClient.SendText(txtSend.Text.Trim() _class);
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}
}
private void btnObj_Click(object sender EventArgs e)
{
List lstEntity = new List();
for (int i = 0; i < 100; i++)
{
Entity entity = new Entity();
entity.StrInfo = txtSend.Text.Trim();
lstEntity.Add(entity);
}
try
{
byte _class = 10;
tcpClient.Sendobject(lstEntity _class);
}
catch (Exception ee)
{
MessageBox
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1921 2011-03-22 20:00 MySocket\MySocket.sln
..A..H. 40960 2011-03-26 14:31 MySocket\MySocket.suo
文件 12800 2011-03-26 14:01 MySocket\SocketClient\bin\Debug\SocketClient.exe
文件 30208 2011-03-26 14:01 MySocket\SocketClient\bin\Debug\SocketClient.pdb
文件 26112 2011-03-26 14:01 MySocket\SocketClient\bin\Debug\TcpIpSocketServer.dll
文件 81408 2011-03-26 14:01 MySocket\SocketClient\bin\Debug\TcpIpSocketServer.pdb
文件 35915 2011-03-22 22:11 MySocket\SocketClient\bin\Debug.rar
文件 3974 2011-03-24 09:40 MySocket\SocketClient\Client.cs
文件 9009 2011-03-23 12:48 MySocket\SocketClient\Client.Designer.cs
文件 5814 2011-03-23 12:48 MySocket\SocketClient\Client.resx
文件 350 2011-03-23 19:47 MySocket\SocketClient\Entity.cs
文件 5632 2011-03-24 09:19 MySocket\SocketClient\obj\Debug\Refactor\SocketClient.exe
文件 3189 2011-03-26 14:01 MySocket\SocketClient\obj\Debug\ResolveAssemblyReference.cache
文件 180 2011-03-26 14:01 MySocket\SocketClient\obj\Debug\SocketClient.Client.resources
文件 650 2011-03-22 20:30 MySocket\SocketClient\obj\Debug\SocketClient.csproj.FileListAbsolute.txt
文件 848 2011-03-23 12:48 MySocket\SocketClient\obj\Debug\SocketClient.csproj.GenerateResource.Cache
文件 12800 2011-03-26 14:01 MySocket\SocketClient\obj\Debug\SocketClient.exe
文件 30208 2011-03-26 14:01 MySocket\SocketClient\obj\Debug\SocketClient.pdb
文件 180 2011-03-26 14:01 MySocket\SocketClient\obj\Debug\SocketClient.Properties.Resources.resources
文件 494 2011-03-22 19:34 MySocket\SocketClient\Program.cs
文件 1380 2011-03-22 19:34 MySocket\SocketClient\Properties\AssemblyInfo.cs
文件 2874 2011-03-22 19:34 MySocket\SocketClient\Properties\Resources.Designer.cs
文件 5612 2011-03-22 19:34 MySocket\SocketClient\Properties\Resources.resx
文件 1097 2011-03-22 19:34 MySocket\SocketClient\Properties\Settings.Designer.cs
文件 249 2011-03-22 19:34 MySocket\SocketClient\Properties\Settings.settings
文件 4051 2011-03-22 22:24 MySocket\SocketClient\SocketClient.csproj
文件 12800 2011-03-26 14:01 MySocket\SocketServer\bin\Debug\SocketClient.exe
文件 30208 2011-03-26 14:01 MySocket\SocketServer\bin\Debug\SocketClient.pdb
文件 12800 2011-03-26 14:01 MySocket\SocketServer\bin\Debug\SocketServer.exe
文件 26112 2011-03-26 14:01 MySocket\SocketServer\bin\Debug\SocketServer.pdb
............此处省略66个文件信息
- 上一篇:intel ipp 6.1 破解码 注册
- 下一篇:查询今日宝贝销量小工具
相关资源
- 安卓手机socket通信服务端和客户端
- 考试系统程序包括客户端服务端sock
- led屏发布系统 通信加密解密 socket通
- 安卓app之间的socket通信,支持多线程
- 局域网聊天工具socket通信技术
- 聊天 socket通信
- socket通信以及发送消息接收消息
- QT_的socket_与_Linux_的socket通信Linux
- 基于TCP,socket通信,简单小程序
- linux ipv6简单tcp/udp socket通信
- 套接字Socket通信TCP聊天程序含界面
- 有连接的socket通信posix)
- 五子棋局域网联机版
- socket通信 基于udp
- 华农网络编程socket通信
- Qt 下的udp socket通信
- 仿QQ版socket通信.rar仿QQ版socket通信.r
- 基于linux下用c编写的socket通信传输文
- Socket通信发送端向接收端发送图片D
- socket通信 server对client client对client
- Socket通信实现多人聊天应用
- Socket通信.zip
- ios-Socket通信.zip
- linux下多线程socket通信完整源码文件
- 中南大学实验:SOCKET通信UDP协议-发送
- linux环境下基于socket通信的ftp系统
- socket连接传送数据,控制家电led
- 基于QT5编写的TCP SOCKET通信小demo程序,
- 树莓派使用python与云服务器进行sock
- Qt5 UDP Socket通信源码
评论
共有 条评论