最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
实例解析SOCKET编程模型(二)
时间:2022-07-02 18:02:56 编辑:袖梨 来源:一聚教程网
以下是同步聊天程序的客户端源代码。其中的一些过程可以参考服务器端源码
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
namespace 聊天_socket_client
{
///
/// Form1 的摘要说明。
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnStop;
private System.Windows.Forms.Button btnSend;
private System.Windows.Forms.TextBox txtPort;
private System.Windows.Forms.TextBox txtServer;
private System.Windows.Forms.RichTextBox rtbSend;
private System.Windows.Forms.RichTextBox rtbReceive;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.Button btnConnect;
private IPAddress hostIPAddress;
private IPEndPoint Server;
private Socket sock;
///
/// 必需的设计器变量。
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
namespace 聊天_socket_client
{
///
/// Form1 的摘要说明。
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnStop;
private System.Windows.Forms.Button btnSend;
private System.Windows.Forms.TextBox txtPort;
private System.Windows.Forms.TextBox txtServer;
private System.Windows.Forms.RichTextBox rtbSend;
private System.Windows.Forms.RichTextBox rtbReceive;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.Button btnConnect;
private IPAddress hostIPAddress;
private IPEndPoint Server;
private Socket sock;
///
/// 必需的设计器变量。
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
相关文章
- 斗罗大陆猎魂世界武魂融合技如何发动 07-08
- 必须拿住:迈克尔·赛勒发布比特币牛市图表 07-08
- 大侠立志传爱猫失踪任务完成指南 07-08
- DOTA2电竞世界杯2025赛程一览 07-08
- YellowPencil Pro v7.6.7 WordPress 可视化 CSS 编辑插件 07-08
- 魔兽世界强力巨魔之血药水怎么获得-强力巨魔之血药水获取方法 07-08