Go Back   RunUO - Ultima Online Emulation > RunUO > Core Modifications > Other

Other Cant find a category above, use this one! Core mods not listed above go here!

Reply
 
Thread Tools Display Modes
Old 07-11-2005, 04:32 PM   #1 (permalink)
Forum Novice
 
Join Date: Oct 2003
Location: Vienna, Austria
Age: 21
Posts: 127
Send a message via ICQ to Arahil
Default 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)

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 );

	if (m_Listener == null) {
		Console.WriteLine("RunUO failed to bind the Socket. You may not be able to connect to the server");
	} else {

		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.
Arahil is offline   Reply With Quote
Old 07-16-2005, 05:36 PM   #2 (permalink)
Forum Expert
 
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
Default

that is not exception handling, that is debugging..

and i can not see any port number in that debug message
noobie is offline   Reply With Quote
Old 07-16-2005, 07:15 PM   #3 (permalink)
Forum Expert
 
Ohms_Law's Avatar
 
Join Date: Sep 2004
Age: 37
Posts: 1,006
Default

actually, I disagree. Another app is a possibility, but there's other things that bind ports. bad drivers, power failures, other wierdness. I've seen a problem where every time the server conputer was restarted, the damn NIC wouldn't restart.
Better to get an exception than be in the dark about it.
Ohms_Law is offline   Reply With Quote
Old 07-16-2005, 07:30 PM   #4 (permalink)
RunUO Developer/Demise Person
 
ASayre's Avatar
 
Join Date: Mar 2003
Location: California
Age: 20
Posts: 1,700
Default

Actually, something to deal with it not binding to the socket was already put in place for the next version of RunUO atleast a month ago
__________________
Andre Sayre, Core Developer
The RunUO Software Team

The day we are born is the day Death inches ever closer...
E-mail: ASayre ( AT ) RunUO ( Dot ) c o m
I'm as graceful as a gazelle galloping over glistening green grass with it's head on fire.
ASayre is offline   Reply With Quote
Old 07-16-2005, 07:45 PM   #5 (permalink)
Forum Expert
 
Ohms_Law's Avatar
 
Join Date: Sep 2004
Age: 37
Posts: 1,006
Default

well then, there we go..
Ohms_Law is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5