c# tcp调试助手源代码Word文档格式.docx
- 文档编号:16065836
- 上传时间:2022-11-18
- 格式:DOCX
- 页数:21
- 大小:18.81KB
c# tcp调试助手源代码Word文档格式.docx
《c# tcp调试助手源代码Word文档格式.docx》由会员分享,可在线阅读,更多相关《c# tcp调试助手源代码Word文档格式.docx(21页珍藏版)》请在冰豆网上搜索。
试?
助ú
手?
{
publicpartialclassForm1:
Form
/*****服务?
端?
*******/
privateintserve_portNum=13;
privateTcpListenerserve_listener=null;
//服务?
器÷
与?
客í
户§
机ú
之?
连?
接ó
状痢?
态?
privateboolbserve_Connected=false;
侦ì
听瑈线?
程ì
privateThreadtserve_AcceptMsg=null;
//网?
络?
访?
问ê
基ù
础?
数簓据Y流ⅰ?
privateNetworkStreamnStream_serve=null;
//创洹?
建¨
读á
取?
privateTextReadertReader_serve=null;
编括?
写′器÷
privateTextWriterwReader_serve=null;
/*****客í
privateintClient_portNum=13;
//客í
privateTcpClientclient_client=null;
服务?
privateboolbclient_Connected=false;
privateThreadtclient_AcceptMsg=null;
privateNetworkStreamnStream_client=null;
privateTextReadertReader_client=null;
privateTextWriterwReader_client=null;
//接ó
收?
、¢发ぁ?
送í
数簓据Y池?
长¤
度è
privateconstintbytelength=1024;
池?
byte[]serve_rec_buff=newbyte[bytelength];
发ぁ?
byte[]serve_send_buff=newbyte[bytelength];
byte[]client_rec_buff=newbyte[bytelength];
byte[]client_send_buff=newbyte[bytelength];
publicForm1()
InitializeComponent();
rb_xs_zf.Checked=true;
rb_fs_zf.Checked=true;
rb_fwq.Checked=true;
cb_fs_cf.Checked=false;
btn_Qidong.Enabled=false;
//timer1=new
timer1.Stop();
timer2.Stop();
}
privatevoidtextBox1_TextChanged(objectsender,EventArgse)
privatevoidlabel2_Click(objectsender,EventArgse)
privatevoidtextBox1_TextChanged_1(objectsender,EventArgse)
启?
动ˉ
privatevoidQidong_btn_Click(objectsender,EventArgse)
serve_portNum=int.Parse(tbx_lport.Text);
stringstrlocalip=cBox_localip.Text;
IPAddresslocaladdr=null;
localaddr=IPAddress.Parse(strlocalip);
//listener=newTcpListener(strlocalip,serve_portNum);
//IPAddresslocaladdr=host.AddressList[0];
//stringipAddress=host.AddressList[0].ToString();
//tbx_Local_IP.Text=ipAddress;
serve_listener=newTcpListener(localaddr,serve_portNum);
lab_serve.Text="
正y在ú
等台?
待鋣连?
...."
;
serve_listener.Start();
tserve_AcceptMsg=newThread(newThreadStart(this.AcceptMessage));
tserve_AcceptMsg.Start();
privatevoidlianjie_btn_Click(objectsender,EventArgse)
stringhostName=tbx_serveIP.Text;
Client_portNum=Convert.ToInt32(tbx_sport.Text);
try
client_client=newTcpClient(hostName,Client_portNum);
if(client_client.Connected)
tclient_AcceptMsg=newThread(newThreadStart(this.Client_AcceptMessage));
tclient_AcceptMsg.Start();
btn_lianjie.Enabled=false;
lab_client.Text="
ok!
?
上?
:
阰"
+hostName+"
,?
口ú
号?
+tbx_sport.Text;
catch
!
没?
有瓺连?
字?
符?
数簓据Y
publicvoidserve_sendstr(stringstrsend)
//richTextBox2_KeyPress()和í
AcceptMessage()
//都?
将?
向ò
richTextBox1写′字?
可é
能ü
有瓺冲?
突?
//所ù
以?
需è
要瘾多à
线?
互¥斥a
lock(this)
tx_serve_rec.AppendText("
+strsend+"
\n"
);
聊?
天?
信?
息¢写′入?
网?
流ⅰ?
便?
wReader_serve.WriteLine(strsend);
//清?
理え?
当獭?
前°
缓o冲?
区?
数簓据Y,?
使?
所ù
有瓺缓o冲?
数簓据Y写′入?
设Θ?
备?
wReader_serve.Flush();
MessageBox.Show("
无T法ぁ?
通?
!
"
节ú
数簓组哩?
publicvoidserve_sendhex(stringInputString)
#region增?
处锔理え?
string[]HexStrSplit=InputString.Split('
'
intlen=HexStrSplit.Length;
byte[]arr=newbyte[len];
for(intii=0;
ii<
arr.Length;
ii++)
arr[ii]=Convert.ToByte(HexStrSplit[ii],16);
stringstrtem="
strtem+=String.Format("
0x{0:
X2}"
arr[ii]);
#endregion
+strtem+"
nStream_serve.Write(arr,0,arr.Length);
//nStream_serve.Flush();
privatevoidbutton1_Click(objectsender,EventArgse)
if(bserve_Connected)
if(cb_fs_cf.Checked==true)
timer1.Interval=Convert.ToInt32(tbx_fs_time.Text);
timer1.Start();
else
if(rb_fs_zf.Checked==true)
serve_sendstr(tx_serve_send.Text);
elseif(rb_fs_hex.Checked==true)
serve_sendhex(tx_serve_send.Text);
未′与?
立ⅰ?
不?
。
£"
//定¨
时骸?
privatevoidontime(objectsender,EventArgse)
serve_sendstr(tx_ser
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- c# tcp调试助手源代码 tcp 调试 助手 源代码
![提示](https://static.bdocx.com/images/bang_tan.gif)