[Mono-list] How to listen on local socket
Steve Mentzer
steve@mudflapsoftware.com
Fri, 1 Aug 2003 07:59:51 -0700
i am paraphrasing here, but I believe the proper approach is....
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 4444); // connect
to port
----- Original Message -----
From: "Jörg Rosenkranz" <joergr@voelcker.com>
To: <mono-list@ximian.com>
Sent: Friday, August 01, 2003 7:35 AM
Subject: [Mono-list] How to listen on local socket
Maybe this is a simple question but I'm desperately searching a way to do
this:
I want create a TCP server app and need to listen to a local socket.
How do I create the local endpoint?
I tried it 2 different ways:
1)
IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName()); // get local
Hostname
IPAddress ipAddress = ipHostInfo.AddressList[0]; // get first IP-Address
from Host
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 4444); // connect to
port
This works under Windows but under Linux/Mono the address is 127.0.0.1.
Other addresses aren't in the AddressList.
I know this is not the preferred way.
2)
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 4444);
This works under Windows, too. Linux: Loopback device...
How do I get the right IP address for the first (all?) network card(s)?
Thanks,
Joerg
_______________________________________________
Mono-list maillist - Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list