0
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace PDMS_TCG
{
public partial class FormHost : Form
{
public FormHost()
{
InitializeComponent();
}
private void btnConnect_Click(object sender, EventArgs e)
{
{
IPAddress ipAd = IPAddress.Parse(txtAddress.Text);
TcpListener myList = new TcpListener(ipAd, int.Parse(txtPort.Text));
myList.Start();
Socket s = myList.AcceptSocket();
RPS rps = new RPS();
rps.Show();
}
}
private void btnHost_Click(object sender, EventArgs e)
{
IPAddress ipAd = IPAddress.Parse(GV.strAddress);
TcpListener myList = new TcpListener(ipAd, int.Parse(txtPort.Text));
myList.Start();
Socket s = myList.AcceptSocket();
}
}
}
txtAddress = IP主機C#TCP Server幫助
txtPort =端口號
的地址我有一些混亂的TcpListener /套接字的條款。有人可以幫我修復這段代碼嗎?點擊btnHost讓你主持連接,然後btnConnect連接到主機。另外,一旦連接,我怎麼能有一個事件觸發另一臺計算機上的事件?