资源简介
C#网络编程TCP通信实例程序简单设计
程序介绍和下载连接地址。。。https://www.cnblogs.com/JiYF/p/6699104.html
本站太贵了
代码片段和文件信息
/*****************************************************
* ProjectName: BenXHSocket
* Description:
* ClassName: BxhTcpClient
* CLRVersion: 4.0.30319.42000
* Author: JiYF
* NameSpace: BenXHSocket
* MachineName: JIYF_PC
* CreateTime: 2017/3/31 20:31:48
* UpdatedTime: 2017/3/31 20:31:48
*****************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace BenXHSocket
{
public class BXHTcpClient : Socketobject
{
bool IsClose = false;
///
/// 当前管理对象
///
Sockets sk;
///
/// 客户端
///
public TcpClient client;
///
/// 当前连接服务端地址
///
IPAddress Ipaddress;
///
/// 当前连接服务端端口号
///
int Port;
///
/// 服务端IP+端口
///
IPEndPoint ip;
///
/// 发送与接收使用的流
///
NetworkStream nStream;
///
/// 初始化Socket
///
///
///
public override void InitSocket(string ipaddress int port)
{
Ipaddress = IPAddress.Parse(ipaddress);
Port = port;
ip = new IPEndPoint(Ipaddress Port);
client = new TcpClient();
}
public static PushSockets pushSockets;
public void SendData(string SendData)
{
try
{
if (client == null || !client.Connected)
{
Sockets sks = new Sockets();
sks.ex = new Exception(“客户端无连接..“);
sks.ClientDispose = true;
pushSockets.Invoke(sks);//推送至UI
}
if (client.Connected) //如果连接则发送
{
if (nStream == null)
{
nStream = client.GetStream();
}
byte[] buffer = Encoding.UTF8.GetBytes(SendData);
nStream.Write(buffer 0 buffer.Length);
}
}
catch (Exception skex)
{
Sockets sks = new Sockets();
sks.ex = skex;
sks.ClientDispose = true;
pushSockets.Invoke(sks);//推送至
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-04-25 17:51 BenXHSocket\
目录 0 2017-04-10 20:33 BenXHSocket\BenXHSocket\
文件 2021 2017-03-31 14:25 BenXHSocket\BenXHSocket.sln
文件 87040 2017-04-10 22:02 BenXHSocket\BenXHSocket.v12.suo
目录 0 2017-04-10 22:01 BenXHSocket\BenXHSocketClient\
文件 4001 2017-04-09 14:16 BenXHSocket\BenXHSocketClient\BenXHSocketClient.csproj
目录 0 2017-04-10 20:33 BenXHSocket\BenXHSocketClient\bin\
目录 0 2017-04-10 20:33 BenXHSocket\BenXHSocketClient\bin\Debug\
文件 11264 2017-04-01 13:19 BenXHSocket\BenXHSocketClient\bin\Debug\BenXHSocket.dll
文件 34304 2017-04-01 13:19 BenXHSocket\BenXHSocketClient\bin\Debug\BenXHSocket.pdb
文件 13824 2017-04-09 13:48 BenXHSocket\BenXHSocketClient\bin\Debug\BenXHSocketClient.exe
文件 42496 2017-04-09 13:48 BenXHSocket\BenXHSocketClient\bin\Debug\BenXHSocketClient.pdb
文件 24216 2017-04-09 13:52 BenXHSocket\BenXHSocketClient\bin\Debug\BenXHSocketClient.vshost.exe
文件 490 2013-03-18 17:00 BenXHSocket\BenXHSocketClient\bin\Debug\BenXHSocketClient.vshost.exe.manifest
目录 0 2017-03-31 14:17 BenXHSocket\BenXHSocketClient\bin\Release\
文件 4083 2017-04-10 22:01 BenXHSocket\BenXHSocketClient\FrmTCPClient.cs
文件 10631 2017-03-31 20:56 BenXHSocket\BenXHSocketClient\FrmTCPClient.Designer.cs
文件 5817 2017-03-31 20:56 BenXHSocket\BenXHSocketClient\FrmTCPClient.resx
目录 0 2017-04-10 20:33 BenXHSocket\BenXHSocketClient\obj\
目录 0 2017-04-10 22:01 BenXHSocket\BenXHSocketClient\obj\Debug\
文件 5869 2017-04-10 22:01 BenXHSocket\BenXHSocketClient\obj\Debug\BenXHSocketClient.csproj.FileListAbsolute.txt
文件 984 2017-03-31 20:58 BenXHSocket\BenXHSocketClient\obj\Debug\BenXHSocketClient.csproj.GenerateResource.Cache
文件 14806 2017-04-10 22:01 BenXHSocket\BenXHSocketClient\obj\Debug\BenXHSocketClient.csprojResolveAssemblyReference.cache
文件 13824 2017-04-10 22:01 BenXHSocket\BenXHSocketClient\obj\Debug\BenXHSocketClient.exe
文件 180 2017-04-10 22:01 BenXHSocket\BenXHSocketClient\obj\Debug\BenXHSocketClient.FrmTCPClient.resources
文件 32256 2017-04-10 22:01 BenXHSocket\BenXHSocketClient\obj\Debug\BenXHSocketClient.pdb
文件 180 2017-04-10 22:01 BenXHSocket\BenXHSocketClient\obj\Debug\BenXHSocketClient.Properties.Resources.resources
文件 1453 2017-04-01 13:19 BenXHSocket\BenXHSocketClient\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6857 2017-04-10 22:01 BenXHSocket\BenXHSocketClient\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2017-03-31 14:17 BenXHSocket\BenXHSocketClient\obj\Debug\TempPE\
文件 505 2017-03-31 14:26 BenXHSocket\BenXHSocketClient\Program.cs
............此处省略79个文件信息
评论
共有 条评论