[Solved] Given a TCP server, how to get the connection domain address


What you are trying to do is not possible with plain TCP. TCP works on plain IP-Addresses without domains.

To explain what is going on:

When you are establishing a connection to, e.g. example.com, first of all a DNS Lookup for example.com is done. In this case, the DNS Lookup would result in 93.184.216.34. You can read more about DNS here.

A TCP Connection with 93.184.216.34 is established after that, the original domain name is not sent with the request.

Because you sometimes need the original name the user was trying to connect to, some protocols send the domain name after connecting. HTTP for example does this via the Host header.

Maybe you can do something like that and require to send the original host first through your TCP Connection!

1

solved Given a TCP server, how to get the connection domain address