资源简介
C# Socket 分包传送数据是关于图片传送并且分割字节的一个资源。

代码片段和文件信息
using System;
using System.IO;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Windows.Forms;
namespace NetClient
{
/**////
/// TCPIPClient 提供在Net TCP_IP 协议上基于消息的客户端
///
public class TCPIPClient : System.ComponentModel.Component
{
private int bufferSize=1024;
private string tcpIpServerIP=“127.0.0.1“;
private int tcpIpServerPort=11000;
private Socket ClientSocket=null;
private ManualResetEvent connectDone = new ManualResetEvent(false);
private IContainer components;
private ManualResetEvent sendDone = new ManualResetEvent(false);
private void ConnectCallback(IAsyncResult ar)
{
try
{
Socket client = (Socket) ar.AsyncState;
client.EndConnect(ar);
}
catch (Exception e)
{
onerrorEvent(new ErrorEventArgs(e));
}
finally
{
connectDone.Set();
}
}
private void SendCallback(IAsyncResult ar)
{
try
{
Socket client = (Socket) ar.AsyncState;
int bytesSent = client.EndSend(ar);
//Console.WriteLine(bytesSent);
}
catch (Exception e)
{
onerrorEvent(new ErrorEventArgs(e));
}
finally
{
sendDone.Set();
}
}
private void ReceiveCallback(IAsyncResult ar)
{
Socket handler=null;
try
{
lock(ar)
{
Stateobject state = (Stateobject) ar.AsyncState;
handler = state.workSocket;
int bytesRead = handler.EndReceive(ar);
if (bytesRead > 0)
{
int ReadPiont=0;
while(ReadPiont {
if(state.Cortrol==0 && ReadPiont {
long bi1=state.buffer[ReadPiont];
bi1=(bi1<<24)&0xff000000;
state.packSize=bi1;
ReadPiont++;
state.Cortrol=1;
}
if(state.Cortrol==1 && ReadPiont {
long bi1=state.buffer[ReadPiont];
bi1=(bi1<<16)&0x00ff0000;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 19788 2007-09-05 23:05 C# Socket 分包传送数据\ServerSocket.cs
文件 5660 2009-11-26 18:08 C# Socket 分包传送数据\ClientSocket.resx
文件 17015 2007-09-05 23:17 C# Socket 分包传送数据\ClientSocket.cs
目录 0 2010-08-26 09:02 C# Socket 分包传送数据
----------- --------- ---------- ----- ----
42463 4
- 上一篇:L网上校友录设计与实现(源代码+论文)
- 下一篇:flash图片上传插件
相关资源
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
评论
共有 条评论