Fix for binding Socket
This one has also been in the Bugtracker for quite a while now, and i'll post a fix for it here:
The problem is that RunUO does not print an error message if it fails to bind the socket. So it may be that you fail to connect to you server, because another application is using the port, but you are not informed about the socket error.
So here is a possible fix for that - there are more possibilities to do that, but i thought this is the most simple one
Since Listener.Bind(IPAddress, int) returns a Socket object i just check if this returned object is null, which means, that an exception occured in this method. I do this check directly after Listener.Bind(IPAddress, int) is called in Listener..ctor(int)
Considering that Listener.cs provides some of the really, really basic functionality of RunUO the exception handling is way too weak in my opinion.
This one has also been in the Bugtracker for quite a while now, and i'll post a fix for it here:
The problem is that RunUO does not print an error message if it fails to bind the socket. So it may be that you fail to connect to you server, because another application is using the port, but you are not informed about the socket error.
So here is a possible fix for that - there are more possibilities to do that, but i thought this is the most simple one
Since Listener.Bind(IPAddress, int) returns a Socket object i just check if this returned object is null, which means, that an exception occured in this method. I do this check directly after Listener.Bind(IPAddress, int) is called in Listener..ctor(int)
Code:
public Listener( int port )
{
m_ThisPort = port;
m_Disposed = false;
m_Accepted = new Queue();
m_OnAccept = new AsyncCallback( OnAccept );
m_Listener = Bind( IPAddress.Any, port );
[B]if (m_Listener == null) {
Console.WriteLine("RunUO failed to bind the Socket. You may not be able to connect to the server");
} else {[/B]
try {
IPHostEntry iphe = Dns.Resolve( Dns.GetHostName() );
ArrayList list = new ArrayList();
list.Add( IPAddress.Loopback );
Console.WriteLine( "Address: {0}:{1}", IPAddress.Loopback, port );
IPAddress[] ips = iphe.AddressList;
for ( int i = 0; i < ips.Length; ++i ) {
if ( !list.Contains( ips[i] ) ) {
list.Add( ips[i] );
Console.WriteLine( "Address: {0}:{1}", ips[i], port );
}
}
}
catch {
}
}
}
Considering that Listener.cs provides some of the really, really basic functionality of RunUO the exception handling is way too weak in my opinion.