-
C#实现Socket通讯Demo
c#通过Socket实现图片、文件和文字的通讯。
private void button1_Click(object sender, EventArgs e)
{
try
{
server = TxStart.startServer(int.Parse(textBox_port.Text));
server.AcceptString = new TxDelegate(acceptString);
server.AcceptByte = new TxDelegate(acceptBytes);
server.Connect = new TxDelegate(connect);
server.dateSuccess = new TxDelegate(dateSuccess);
server.Disconnection = new TxDelegate(disconnection);
server.EngineClose = new TxDelegate(engineClose);
server.EngineLost = new TxDelegate(engineLost);
//server.BufferSize=12048;
//server.FileLog = "C:\test.txt";
server.StartEngine();
this.button1.Enabled = false;
this.button2.Enabled = true;
this.button3.Enabled = true;
}
catch (Exception Ex) { MessageBox.Show(Ex.Message); }
}
///
/// 发送按钮
///
///
///
private void button2_Click(object sender, EventArgs e)
{
try
{
IPEndPoint client = (IPEndPoint)this.comboBox1.SelectedItem;
if (client == null)
{
MessageBox.Show("没有选中任何在线客户端!");
return;
}
if (!this.server.clientCheck(client))
{
MessageBox.Show("目标客户端不在线!");
return;
}
server.sendMessage(client, textBox_msg.Text);
}
catch (Exception Ex) { MessageBox.Show(Ex.Message); }
}
///
/// 下面显示的
///
///
///
private void show(IPEndPoint ipEndPoint, string str)
{
label_zt.Text = ipEndPoint.ToString() ":" str;
label_all.Text = "当前在线人数:" this.server.ClientNumber.ToString();
}
///
/// 当组合框按下的时候
///
///
///
private void comboBox1_DropDown_1(object sender, EventArgs e)
{
try
{
List list = this.server.ClientAll;
this.comboBox1.DataSource = list;
}
catch { }
}
///
/// 关闭客户端的按钮
///
///
///
private void button3_Click_1(object sender, EventArgs e)
{
IPEndPoint client = (IPEndPoint)this.comboBox1.SelectedItem;
if (client == null)
{
MessageBox.Show("没有选中任何在线客户端!");
return;
}
if (!this.server.clientCheck(client))
{
MessageBox.Show("目标客户端不在线!");
return;
}
server.clientClose(client);
}
#endregion
- 2021-08-22 00:31:02下载
- 积分:1
-
WPF连接数据库实例
一个使用WPF技术连接数据库的例子,通过将查询到的数据绑定到一个DataGrid上,使程序与数据库数据同步显示。
- 2022-02-04 09:51:22下载
- 积分:1
-
eyedetect
eye detection by opencv .please confirm to me. Thanks
- 2009-10-23 12:48:45下载
- 积分:1
-
RX23T_MRSSK_SPM_LESS_FOC_CSP_RV101
PMSM 180°正弦波无位置传感器FOC程序(PMSM 180 sensorless FOC program.)
- 2021-04-27 13:08:45下载
- 积分:1
-
UART模块通信例子
说明: 基于STC51单片机使用UART串口模块通讯例子(STC51 using UART serial port module communication example)
- 2020-06-17 13:40:02下载
- 积分:1
-
Keil-RTX-RTOS
Real Time Oparation System (RTX)
- 2015-03-15 15:07:34下载
- 积分:1
-
key_input
linux驱动按键的输入子系统,驱动按键linux(Linux driver input subsystem keys, key drivers linux)
- 2016-02-16 20:00:34下载
- 积分:1
-
C51tlv5616
自己编写12位DACTLV5616驱动程序头文件,验证成功。(I have written 12 DACTLV5616 driver header files, the validation is successful.)
- 2013-09-03 08:24:26下载
- 积分:1
-
c# 简单的借书/还书 示例源码
c# 简单的借书/还书 示例源码
- 2014-03-10下载
- 积分:1
-
ipmsg342_installer
ip messanger installer
- 2013-12-31 03:08:57下载
- 积分:1