あなたのような、あなたが何かを行うことができます接続するためのTCPソケットを使用している場合:ものはソケットを作成中にポート番号を指定していけない場合OSが使用可能なデフォルトが割り当てられますよりも、ということである
private TcpClient GetClient()
{
TcpClient client = null;
if (!string.IsNullOrEmpty(IpAddress)) // Get IpAddress from config
{
IPAddress ipAddress = null;
IPAddress.TryParse(IpAddress, out ipAddress);
if (ipAddress != null)
{
int intIpAddress = BitConverter.ToInt32(ipAddress.GetAddressBytes(), 0);
IPAddress clientBindingIp = new IPAddress(BitConverter.GetBytes(intIpAddress));
IPEndPoint endpoint = new IPEndPoint(clientBindingIp, 0); // Specify 0 for OS to automatically assign, or read from config here
client = new TcpClient(endpoint);
}
}
return client;
}
ポート番号。または、あなたが望むならConfigからそれを読むことができます
"ダイナミックポート"を探したり、サービスを実行するユーザーにポートを登録して、そのユーザーだけがこのポートを使用できるようにする必要があります。 – Rabban
あなたはポート番号だけを必要とするのでしょうか、それとも今後サービスが受けるべき情報はもっとたくさんありますか?サービスとWPFアプリケーションの両方が同じマシンにありますか? –
ポート番号だけを変更する必要があり、両方とも同じマシン上にある。私は "Dyanmic Port"について知りませんでしたので、私はそれを調べることができます。 – MutantKeyboard