C# Tutorial - Simple Threaded TCP Server

C# Tutorials 自己编写的dotnet入门代码案例 阅读详情

In this tutorial I'm going to show you how to build a threaded tcp server with C#. If you've ever worked with Window's sockets, you know how difficult this can sometimes be. However, thanks to the .NET framework, making one is a lot easier than it used to be.
What we'll be building today is a very simple server that accepts client connections and can send and receive data. The server spawns a thread for each client and can, in theory, accept as many connections as you want (although in practice this is limited because you can only spawn so many threads before Windows will get upset).

Let's just jump into some code. Below is the basic setup for our TCP server class.

using System;
using System. Text;
using System. Net. Sockets;
using System. Threading;
using System. Net;

namespace TCPServerTutorial
{
    class Server
    {
      private TcpListener tcpListener;
      private Thread listenThread;

      public Server ( )
      {
          this. tcpListener =
            new TcpListener (IPAddress. Any, 3000 );
          this. listenThread =
            new Thread ( new ThreadStart (ListenForClients ) );
     
          this. listenThread. Start ( );
      }
    }
}


So here's a basic server class - without the guts. We've got a TcpListener which does a good job of wrapping up the underlying socket communication, and a Thread which will be listening for client connections. You might have noticed the function ListenForClients that is used for our ThreadStart delegate. Let's see what that looks like.

private void ListenForClients ( )
{
    this. tcpListener. Start ( );

    while ( true )
    {
      //blocks until a client has connected to the server
      TcpClient client = this. tcpListener. AcceptTcpClient ( );

      //create a thread to handle communication
      //with connected client
      Thread clientThread =
          new Thread ( new
         ParameterizedThreadStart (HandleClientComm ) );
      clientThread. Start (client );
    }
}


This function is pretty simple. First it starts our TcpListener and then sits in a loop accepting connections. The call to AcceptTcpClient will block until a client has connected, at which point we fire off a thread to handle communication with our new client. I used a ParameterizedThreadStart delegate so I could pass the TcpClient object returned by the AcceptTcpClient call to our new thread.

The function I used for the ParameterizedThreadStart is called HandleClientComm. This function is responsible for reading data from the client. Let's have a look at it.

private void HandleClientComm ( object client )
{
   TcpClient tcpClient = (TcpClient )client;
   NetworkStream clientStream = tcpClient. GetStream ( );

    byte [ ] message = new byte [ 4096 ];
    int bytesRead;

    while ( true )
    {
      bytesRead = 0;

      try
      {
          //blocks until a client sends a message
         bytesRead = clientStream. Read (message, 0, 4096 );
      }
      catch
      {
          //a socket error has occured
          break;
      }

      if (bytesRead == 0 )
      {
          //the client has disconnected from the server
          break;
      }

      //message has successfully been received
      ASCIIEncoding encoder = new ASCIIEncoding ( );
      System. Diagnostics. Debug. WriteLine (
         encoder. GetString (message, 0, bytesRead ) );
    }

   tcpClient. Close ( );
}


The first thing we need to do is cast client as a TcpClient object since the ParameterizedThreadStart delegate can only accept object types. Next, we get the NetworkStream from the TcpClient, which we'll be using to do our reading. After that we simply sit in a while true loop reading information from the client. The Read call will block indefinitely until a message from the client has been received. If you read zero bytes from the client, you know the client has disconnected. Otherwise, a message has been successfully received from the server. In my example code, I simply convert the byte array to a string and push it to the debug console. You will, of course, do something more interesting with the data - I hope. If the socket has an error or the client disconnects, you should call Close on the TcpClient object to free up any resources it was using.

Believe it or not, that's pretty much all you need to do to create a threaded server that accepts connections and reads data from clients. However, a server isn't very useful if it can't send data back, so let's look at how to send data to one of our connected clients.

NetworkStream clientStream = tcpClient. GetStream ( );
ASCIIEncoding encoder = new ASCIIEncoding ( );
byte [ ] buffer = encoder. GetBytes ( "Hello Client!" );

clientStream. Write (buffer, 0 , buffer. Length );
clientStream. Flush ( );


Do you remember the TcpClient object that was returned from the call AcceptTcpClient? Well, that's the object we'll be using to send data back to that client. That being said, you'll probably want to keep those objects around somewhere in your server. I usually keep a collection of TcpClient objects that I can use later. Sending data to connected clients is very simple. All you have to do is call Write on the the client's NetworkStream object and pass it the byte array you'd like to send.

Your TCP server is now finished. The hard part is defining a good protocol to use for sending information between the client and server. Application level protocols are generally unique for application, so I'm not going to go into any details - you'll just have to invent you're own.

But what use is a server without a client to connect to it? This tutorial is mainly about the server, but here's a quick piece of code that shows you how to set up a basic TCP connection and send it a piece of data.

TcpClient client = new TcpClient ( );

IPEndPoint serverEndPoint =
    new IPEndPoint (IPAddress. Parse ( "127.0.0.1" ), 3000 );

client. Connect (serverEndPoint );

NetworkStream clientStream = client. GetStream ( );

ASCIIEncoding encoder = new ASCIIEncoding ( );
byte [ ] buffer = encoder. GetBytes ( "Hello Server!" );

clientStream. Write (buffer, 0 , buffer. Length );
clientStream. Flush ( );


The first thing we need to do is get the client connected to the server. We use the TcpClient.Connect method to do this. It needs the IPEndPoint of our server to make the connection - in this case I connect it to localhost on port 3000. I then simply send the server the string "Hello Server!".

One very important thing to remember is that one write from the client or server does not always equal one read on the receiving end. For instance, your client could send 10 bytes to the server, but the server may not get all 10 bytes the first time it reads. Using TCP, you're pretty much guaranteed to eventually get all 10 bytes, but it might take more than one read. You should keep that in mind when designing your protocol.

That's it! Now get out there and clog the tubes with your fancy new C# TCP servers. As always, comments and questions are welcome.

 

**** this blog is copyed  from (http://blog.paranoidferret.com/index.php/2007/10/30/csharp-tutorial-simple-threaded-tcp-server/)

分享一个轻量化的TCP\IP通讯库(Simple TCP) 简单又好用的TCP\IP通讯库--->Simple TCP 阅读详情

相关推荐

使用SimpleTcp.dll完成TCP通信

使用SimpleTCP.dll库完成TCP连接、断开、发送、发送并返回相应、接收事件。

C# 开源类库 SimpleTCP

简介工作中经常遇到需要实现TCP客户端或服务端的时候,如果每次都自己写会很麻烦且无聊,使用SuperSocket库又太大了。这时候就可以使用SimpleTCP了,当然仅限于C#语言。SimpleTCP是一个简单且非常有用的 .NET 库,用于处理启动和使用 TCP 套接字(客户端和服务器)的重复性任务,使用起来非常方便、代码也少。它的内部不是直接使用的Socket,而是在TcpClient的基础上...

weixin_68436326的博客 1398

C# Tutorial epub

C# Tutorial 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

C#实现简单TCP服务器和客户端网络编程

NetworkStream 类位于 System.Net.Sockets 命名空间中,用于在网络套接字上提供流式数据传输的功能。

book_dw5189的博客 5475

simple-tcp-server:适用于我的外部项目的超级简单易用的tcp服务器

超级简单的TCP服务器和客户端。 创建此项目的目的是,我不必每次都需要重写tcp连接。 这个项目主要是给我的,因此不需要维护代码等。 从服务器向客户端发送请求。 第1步-在ClientHandle中创建方法 在ClientHandle类内部创建一个void方法,并为其提供类类型Packet的参数。 这是将要从服务器调用的方法。 public static void RequestFromServer ( Packet packet ) { } 第2步-在ServerPackets中创建枚举 在PacketHandler内,向ServerPackets添加一个枚举值,并为其赋予与第一步中的方法相同的名称。 public enum ServerPackets { Registration

薄膜电容寿命预测全解析:从理论到实践,5步搞定可靠性评估

本文全面解析薄膜电容寿命预测的理论与实践,提供五步可靠性评估流程,涵盖温度应力、电压应力等关键因素分析,并分享提升寿命的实用技巧。特别适用于新能源、电动汽车等领域的设计工程师,帮助准确预测薄膜电容在实际工况下的使用寿命。

weixin_33712987的博客 432

C# Nuget上一个轻量级TCP\IP通讯库(SimpleTCP)

工作中经常遇到需要实现TCP客户端或服务端的时候,如果每次都自己写会很麻烦且无聊,使用SuperSocket库又太大了。这时候就可以使用。

qq_41184334的博客 3875

LIO-SAM运行报错‘process has died’?别慌,一个命令搞定libmetis.so库路径问题

本文详细解析了LIO-SAM运行中常见的‘process has died’报错问题,特别是由libmetis.so库路径错误导致的节点崩溃。通过一个简单的命令移动库文件到正确位置,即可快速解决这一问题,同时提供了多种替代方案和预防措施,帮助开发者更好地理解Linux动态库加载机制和ROS环境管理。

weixin_29231221的博客 205

C# 使用SimpleTCP再次连接失败问题

使用SimpleTcpServer server = new SimpleTcpServer();创建连接后,若连接过客户端,只是关闭server.stop();再次连接server时将无法使用,需要将连接的客户端close才可以;

只是回忆 442

Information Fusion投稿避坑指南:从初稿到返修的完整流程解析(附模板下载)

本文详细解析了向Information Fusion投稿的全流程,从初稿准备到返修策略,涵盖了22个关键细节。特别强调了投稿前的隐形门槛、LaTeX模板的字体陷阱、图表规范要求以及返修回复的进阶技巧,帮助研究者避免常见错误,提升稿件接受率。附有实用模板下载,助力学术写作效率提升。

tgb34567890的博客 1420

西门子触摸屏教程wincc flexible2008 sp5 Smart V3 V4中文版软件

西门子触摸屏教程wincc flexible2008 sp5 Smart V3 V4中文版软件

liang007dudu的博客 1万+

C# Tutorial For Beginners

So you just install .NET framework and want to start using C# but you dont know where to start ? well…First you could download this complete tutorial here. There is a directory for each tutorial wi

一路向东 1400

用 Joule 点燃 ABAP 开发者的舞台感:SAP BTP 上的 ABAP AI 能力实战解读

摘要:SAP推出的Joule for developers和ABAP AI功能为开发者提供了智能辅助工具,旨在优化ABAP开发流程。主要功能包括上下文感知的代码预测补全、代码解释、单元测试生成和开发问题实时解答。这些能力特别适合应对Cloud环境下ABAP开发的复杂约束,如Clean Core原则和受限语法范围。通过减少重复劳动和提升代码理解效率,该工具帮助开发者将注意力集中在业务逻辑而非技术细节上。随着企业加速向S/4HANA迁移,这些AI功能将在遗留代码改造和云适配中发挥更大作用,建议团队将其纳入工程体

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 297

【转载】C# Tutorial - Simple Threaded TCP Server

http://tech.pro/tutorial/704/csharp-tutorial-simple-threaded-tcp-server In this tutorial I'm going to show you how to build a threaded tcp server with C#. If you've ever worked with Window's sockets,...

weixin_30832983的博客 115

把 SM30 用顺:从表设计到权限与传输,全面掌握 SAP Table Maintenance Generator

摘要 SAP的Table Maintenance Generator(TMG)是为配置表维护需求设计的经典工具,能够生成标准化的维护对话框(SM30)。它支持单表、维护视图(多表关联)和视图簇(导航式维护)三种维护对象类型。使用TMG前需注意三个关键设置:1)表维护权限选项;2)交付类(决定数据传输行为);3)客户端字段配置。通过SE54/SE11生成维护对话框时,需选择维护类型(一步/两步)和记录例程(控制传输)。TMG生成的对象包含函数组、屏幕和处理模块,但部分标准框架不可修改。实际应用中,可通过参数事

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 176

【系列05】端侧AI:构建与部署高效的本地化AI模型 第4章:模型量化(Quantization)

量化的基本思想是减少模型中用于表示参数和激活值的比特数。在模型训练时,参数通常使用32位浮点数(FP32)进行存储,这提供了高精度,但也消耗大量的内存和计算资源。量化则将这些32位浮点数转换成低比特数表示,通常是8位整数(INT8)。量化的原理可以概括为:对浮点数范围进行校准,并将其映射到更小的整数范围内。例如,将一个FP32的权重(如-1.5到1.5)映射到INT8的范围(-128到127)。在推理过程中,模型将使用这些低精度的整数进行计算,从而大大减少了所需的计算量。量化带来的主要收益减少模型大小。

学习,输出==》再学习再输出 1213

c# 使用TCP连接(server)

c# 使用TCP连接(server) 效果图 代码实现 用的变量: 1     Thread threadWatch = null; //负责监听客户端的线程 2 Socket socketWatch = null; //负责监听客户端的套接字 3 //创建一个负责和客户端通信的套接字 4 List<Socket> socConnections = new List<Socket>(); 5 List&

Pei_hua100的专栏 6259

Java小白入门200例81之Java接口

作者简介 作者名:编程界明世隐 简介:优快云博客专家,从事软件开发多年,精通Java、JavaScript,博主也是从零开始一步步把学习成长、深知学习和积累的重要性,喜欢跟广大ADC一起打野升级,欢迎您关注,期待与您一起学习、成长、起飞! 引言 很多Java初学者问我,新手明明很用心、很努力学习的Java知识,转头又忘记了,很让人犯愁,小白如何能够快速成长、成为大牛呢? 其实要成为大神的技巧只有一个:“多学多练”,于是明哥就整理了比较典型的练习实例,通过练习能够快速提升编码技巧和熟练度,让你在成为大

编程界明世隐的博客 1358

C#-CronTrigger Tutorial

CronTrigger Tutorial Introduction cron is a UNIX tool that has been around for a long time, so its scheduling capabilities are powerful and proven. The CronTrigger class is based on the scheduling c...

cxu123321的博客 246

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

C#中通过Socket实现一个简单的TCP\IP服务器和客户端的搭建

TCP\IP 是什么? TCP/IP(Transmission Control Protocol/Internet Protocol)即传输控制协议/网间协议,是一个工业标准的协议集,它是为广域网(WANs)设计的。 Socket 是什么? Socket是应用层与TCP/IP协议族通信的中间软件抽象层,它是一组接口。在设计模式中,Socket其实就是一个门面模式,它把复杂的TCP/IP协议族隐藏在Socket接口后面,对用户来说,一组简单的接口就是全部,让Socket去组织数据,以符合指定的协议。 1.

qq_34699535的博客 8575

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

C# 实现简单 TCP/IP Server

using System; using System.IO; using System.Linq; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; namespace TCPnetwork {     class Program     {    

jetpilot的专栏 2214

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

C#TCP 简单版通信 服务端

TCP Socket 通信

dawei.tu的博客 879

C# 的TCPClient 异步连接与异步读数据

转载连接: http://blog.youkuaiyun.com/luckypeng/article/details/27208393 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using 

newbie的博客 5858

C#简单的tcpserver

实现一个简单的TCPserver,用tcplistener实现。 当收到客户端特定信息"101"时,发送给客户端"202“指令。 using System; using System.Text; using System.Net.Sockets; using System.Threading; using System.Net; namespace TCPServerTuto...

weixin_30641999的博客 2139
上一篇: DataTable导出到Excel数据
下一篇: .NET代码生成器下载大全
王子样
博客等级 码龄23年 19粉丝 46原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值