|
亿众国际点对点文件传输程序(23) this.Text = "亿众国际点对点文件传输软体接收端"; this.Load += new System.EventHandler(this.EzoneReceive_Load); this.groupBox1.ResumeLayout(false); this.groupBox3.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.ResumeLayout(false); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new EzoneReceive()); } private void button1_Click(object sender, System.EventArgs e) { //开启接收线程 Thread TempThread=new Thread(new ThreadStart(this.StartReceive)); TempThread.Start(); this.button1.Enabled=false; } private void EzoneReceive_Load(object sender, System.EventArgs e) { //获得本机的IP地址 this.textBox4.Text=Dns.GetHostByName(Dns.GetHostName()).AddressList[0].ToString(); } private void StartReceive() { //指向远程服务端节点 IPEndPoint ipep=new IPEndPoint(IPAddress.Parse(this.textBox1.Text),int.Parse(this.textBox5.Text)); //创建套接字 Socket client=new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); //连接到发送端 client.Connect(ipep); //获得[文件名] string SendFileName=System.Text.Encoding.Unicode.GetString(CommonModule.EzoneModule.ReceiveVarData(client)); this.textBox2.Text=SendFileName; //获得[包的大小] this.textBox3.Text=System.Text.Encoding.Unicode.GetString(CommonModule.EzoneModule.ReceiveVarData(client));
|