0

我正在使用 TcpListener 编写一个简单的 FTP 服务,并且想找出传入呼叫使用的主机名(具有多个子域的域)。

这可能吗?

//Barebone TCPListener example
System.Net.Sockets.TcpListener listener;
listener = new TcpListener(IPAddress.Any, 21)

listener.Start();

TcpClient client = listener.AcceptTcpClient();

//Great, incoming... what domain are they using to call my service?

//This only gives me the local and remote IP..
//IPEndPoint LocalEndPoint = (IPEndPoint)client.Client.LocalEndPoint;
//IPEndPoint RemoteEndPoint = (IPEndPoint)client.Client.RemoteEndPoint;

任何指针都非常感谢。

4

1 回答 1

3

我认为 TCP 基本上没有这些信息。这就是 HTTP 具有“Host”标头以便客户端可以指定它的原因。

本质上,与主机名建立 TCP 连接相当于将主机名解析为地址,然后就好像从未过名称一样建立连接。

于 2012-10-03T10:50:14.277 回答