有時(shí)項(xiàng)目需求中需要服務(wù)器和客戶端同時(shí)在一個(gè)進(jìn)程實(shí)現(xiàn),一邊需要現(xiàn)場(chǎng)接收多個(gè)客戶端的數(shù)據(jù),一邊需要將數(shù)據(jù)匯總后發(fā)送給遠(yuǎn)程服務(wù)器。下面通過實(shí)例演示此項(xiàng)需求。
C#TCP服務(wù)器和客戶端同時(shí)在一個(gè)進(jìn)程實(shí)現(xiàn)的實(shí)例如下:
界面設(shè)計(jì)
文章來源:http://www.zghlxwxcb.cn/news/detail-816076.html
UI文件代碼文章來源地址http://www.zghlxwxcb.cn/news/detail-816076.html
namespace MyTcpSever
{
partial class frmMain
{
/// <summary>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
/// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗體設(shè)計(jì)器生成
到了這里,關(guān)于網(wǎng)絡(luò)通信(13)-C#TCP服務(wù)器和客戶端同時(shí)在一個(gè)進(jìn)程實(shí)現(xiàn)的實(shí)例的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!