I have two .net applications communicating with sockets on port 5672 and everthing works fine. On server side, i open the connection with this simple code lines:
IPAddress localAddr = Dns.GetHostEntry("localhost").AddressList[0];
TcpListener socket = new TcpListener(localAddr, 5672);
socket.Start();
If i try to launch another server app, it fails, telling me that the port is already in use.
I have also the same pair of applications writted in C++ (not by me).
To my surprise, i can launch both C++ and .net server at the same time.
The worst is that my C++ client can´t communicate with my .net server ("connection refused" error).
To understand my problem, i listed the used ports with the command:
netstat -a
And in the result i had:
TCP 0.0.0.0:5672 <--- (this is the c++ server)
TCP [::1] :5672 <--- (this is the .net server)
According to my C# code, souldn't localhost address be 0.0.0.0 or 127.0.0.1?
What's happening on my .net server?
Waht's the meaning of [::1] ?
Note:
If i change my code to:
IPAddress localAddr = new IPAddress(new byte[]{0,0,0,0});
everything works normaly and my C++ client communicate with .net server.