Added an option to bind the datagram socket to a specific

hostname, in hopes of fixing the issue with receiving datagrams 
from the staging server.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5793 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Andrzej Kapolka
2009-05-21 18:04:09 +00:00
parent 6dd16483be
commit d45b0bdb00
2 changed files with 25 additions and 3 deletions
@@ -109,9 +109,20 @@ public class ConnectionManager extends LoopingThread
*/
public void init (int[] ports, int[] datagramPorts)
throws IOException
{
init(ports, datagramPorts, null);
}
/**
* Constructs and initialized a connection manager (binding socket on which it will listen for
* client connections to each of the specified ports).
*/
public void init (int[] ports, int[] datagramPorts, String datagramHostname)
throws IOException
{
_ports = ports;
_datagramPorts = datagramPorts;
_datagramHostname = datagramHostname;
_selector = SelectorProvider.provider().openSelector();
// create our stats record
@@ -390,7 +401,8 @@ public class ConnectionManager extends LoopingThread
_datagramChannel = DatagramChannel.open();
_datagramChannel.configureBlocking(false);
InetSocketAddress isa = new InetSocketAddress(port);
InetSocketAddress isa = (_datagramHostname == null) ?
new InetSocketAddress(port) : new InetSocketAddress(_datagramHostname, port);
_datagramChannel.socket().bind(isa);
registerChannel(_datagramChannel);
log.info("Server accepting datagrams on " + isa + ".");
@@ -1169,6 +1181,7 @@ public class ConnectionManager extends LoopingThread
@Inject(optional=true) protected Authenticator _author = new DummyAuthenticator();
protected int[] _ports, _datagramPorts;
protected String _datagramHostname;
protected Selector _selector;
protected ServerSocketChannel _ssocket;
protected DatagramChannel _datagramChannel;