when I try to connect to a webserver, my "FritzBox" (residential gateway device) is configured to block all connections that connect directly to an IP, not a host name. However, the connect() function only lets me connect using an IP address. How can I connect() to a server using the host name (the way web browsers do)?
Many thanks.
... my "FritzBox" (residential gateway device) is configured to block all connections that connect directly to an IP, not a host name...
It looks like you are trying to bypass the settings of the child protection feature of the Fritzbox. What these settings mean in reality is that it will only allow HTTP connections which have a real hostname inside the Host-header of the HTTP-Request and not connections containing an IP only, i.e. it will allow http://example.com/
but not http://10.10.10.10/
. For an example of the Host header look at the HTTP example request at Wikipedia.