[Mono-list] cannot bind HttpListener to IP address (+ different behavior in mono / .net)
kriss.free at free.fr
Tue Oct 1 07:17:55 UTC 2013
That works on mono if you serve a single dns name, but as soon as you have
two or more, its not a solution: youll then get a
System.Net.Sockets.SocketException: Address already in use. Actually, if
you use dns name as a prefix, you cannot even use both www.example.com and
// example1.com and example2.com both resolve to the same IP
httplistener.Start(); è System.Net.Sockets.SocketException: Address already
Furthermore, on .net, thats not recommended as it would be only possible as
administrator (to bind to port 80 as a non-admin user, you have to set the
urlacl and urlacl only accepts IP address, not dns name).
The only possible difference I see between mono and .net is that .net tries
to resolve the queried hostname into a IP address and to match it with its
list of declared binding IPs. Whereas mono doesnt do it. Shall I open a
ticket in bugzilla?
De : Ian Norton [mailto:inorton at gmail.com]
Envoyé : mardi 1 octobre 2013 08:12
À : Kriss Free
Objet : Re: [Mono-list] cannot bind HttpListener to IP address (+ different
behavior in mono / .net)
I'm 50% sure that you use the DNS name as the prefix you bind to.
On 30 September 2013 21:19, Kriss Free <kriss.free at free.fr> wrote:
When I bind a HttpListener to a specific IP address, any url with an
hostname corresponding to that IP that I open in a browser returns a "Bad
Request (Invalid host)" in mono whereas it runs fins in .Net.
The long story:
I have a server with two IP addresses. A web server (apache) is bound to the
first IP. I want to make httplistener listen on the second IP 192.168.1.2 to
host two websites example1.com and example2.com. I cannot use
httplistener.Prefixes.Add("http://*:80/") because apache is already
listening on the first IP (this is normal and expected). So I used
httplistener.Prefixes.Add("http://192.168.1.2:80/"). The command runs fine
- with mono, if I open in a browser "http://192.168.1.2" it works, but
"http://www.example1.com" leads to a "Bad Request (Invalid host)".
- with .Net, both url works correctly.
Did I miss something?
The tested platforms:
- Mono 3.2.3 on opensuse 12.3
- .NET 4 on Windows 2008R2
Mono-list maillist - Mono-list at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-list