C#TCPClient应用-一个简单的消息发送和接收 TcpSend 窗口用于发送消息,另外写一个用于接收消息的应用程序,消息接受到以后,必须要关闭接收消息的窗口,才能在接收新的消息,不知道怎么能解决这个问题
源代码: 发送消息的窗口代码 using System; using System
Collections
Generic; using System
ComponentModel; using System
Data; using System
Drawing; using System
Text; using System
Windows
Forms; using System
Net; using System
Sockets; using System
IO; namespaceTCPSocket { public partial class FrmTcpSend : Form { public FrmTcpSend() { InitializeComponent(); } private void buttonSendFile_Click(object sender, EventArgs e) { // TcpClienttcpClient = new TcpClient(textBoxHostName
Text, Int32
Parse(textBoxPort
Text)); TcpClienttcpClient = new TcpClient(); tcpClient
Connect(IPAddress
Parse(textBoxHostName
Text), Int32
Parse(textBoxPort
Text)); NetworkStream ns = tcpClient
GetStream(); FileStreamfs = File