- 1、本文档共28页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Socket 编程,一个服务器,多个客户端,互相通信(测试通过)(国外英文资料)
Socket 编程,一个服务器,多个客户端,互相通信(测试通过)(国外英文资料)
Socket programming, a server, multiple clients, communicating with each other
The basic code of a Scoket communication and a basic communication
Implementing a server and an n-client chat
Server:
Using System;
Using System. Collections. Generic;
Using System.Com ponentModel;
Using System. The Data;
Using System. Drawing;
Using System.Net; / / the Endpoint
Using System.Net.Sockets; / / contains sockets
Using System. The Text;
Using System. Windows. Forms;
Using System. The Threading;
Using System. IO;
The namespace Server
{
Public partial class Form1: Form
{
Public _click ()
{
InitializeComponent ();
TextBox. CheckForIllegalCrossThreadCalls = false; / / close the cross-thread changes control check
}
The Socket sokWatch = null; / / the socket that listens for the client segment connection requests
Thread threadWatch = null; / / responsible for invoking the socket and executing the thread that listens for the request
/ / start the listening button
Private void btnStartListen_Click (object sender, EventArgs e)
{
/ / instantiated socket (ip4 addressing protocol, streaming, TCP)
SokWatch = new Socket (ernetwork, SocketType.)
/ / create IP objects
The IPAddress address = IPAddress.parse (txtIP.text. Trim ());
/ / create network node objects that contain IP and port
The IPEndPoint endpoint = new IPEndPoint (address, int.parse (txtport.text.trim ()));
/ / the listening socket is bound to the corresponding IP and port
SokWatch. Bind (endpoint);
/ / set the listening queue length of 10 (and can handle 10 connection requests at the same time)
SokWatch. Listen (10);
ThreadWatch = new Thread (StartWatch);
ThreadWatch. IsBackground = true;
ThreadWatch. Start ();
Txtshow.appendtext ( start server success... \ r \ n );
}
Dictionary string, ConnectionClient dictConn = new Dictionary string, ConnectionClient ();
Bool isWatch = true;
Region 1. Listens on the connection port by the thread
/ / summary
/ / the listener connection port is invo
您可能关注的文档
- intel cpu(国外英文资料).doc
- Inno Setup一个打包安装脚本示范(国外英文资料).doc
- IE及系统限制修复器(国外英文资料).doc
- intel P4编号详解(国外英文资料).doc
- INTER.TXT(国外英文资料).doc
- internet 信息服务 iis是做什么(国外英文资料).doc
- internet1试题(国外英文资料).doc
- Internet原理第一次作业(国外英文资料).doc
- IP分类(国外英文资料).doc
- ip网络的服务质量序言(国外英文资料).doc
- 2025年数字货币监管政策演变与市场趋势研究报告[001].docx
- 2024-各类工程合同范本 .pdf
- 2025年区块链在司法仲裁领域的应用模式研究报告.docx
- 2025年区块链技术在法院内部管理中的应用策略[001].docx
- 2025年云计算基础设施优化与成本控制策略在智慧社区安防中的应用研究.docx
- 2025年互联网企业反垄断监管合规能力提升路径与优化报告[001].docx
- 2025年互联网行业反垄断监管对搜索引擎竞争格局影响分析报告[001].docx
- 幼儿园防煤气中毒主题班会.pptx
- 2025年智能交通出行行业报告:智能交通与智慧城市交通管理融合发展趋势研究挑战[001].docx
- 2025年中国乳制品质量安全监管:企业自律与政府监管协同发展报告.docx
最近下载
- Unit 6 Rain or Shine (第3课时) 课件人教版(2024)英语七年级下册.pptx VIP
- 港珠澳大桥岛隧工程沉管隧道混凝土质量控制措施.pdf
- 2025年中考数学复习热搜题速递之尺规作图(2024年7月).docx
- 股市风险预警机制-深度研究.pptx
- 政策解读2025年中央一号文件PPT.pptx VIP
- 5.0MPa路面抗折混凝土配合比.docx VIP
- 17J927-1 车库建筑构造(OCR).pdf VIP
- XX市疾病预防控制中心-艾滋病HIV筛查实验室管理手册_精品.doc
- 2025年春季小学学校德育工作计划(1975字).docx VIP
- 渤海水泥厂包装车间除尘系统设计.docx
文档评论(0)