mirror of
https://github.com/deavminet/dnetd
synced 2024-09-21 17:53:39 +02:00
Added method, construcListeners()
, to instantiate listeners
This commit is contained in:
parent
b9513bae96
commit
aec29f0fd1
@ -27,7 +27,7 @@ public final class DListener : Thread
|
||||
this.server = server;
|
||||
|
||||
// /* Get the Address */
|
||||
// Address address = addressInfo.address;
|
||||
Address address = addressInfo.address;
|
||||
|
||||
|
||||
|
||||
|
@ -66,8 +66,8 @@ public class DServer : Thread
|
||||
/* Set the server's config */
|
||||
this.config = config;
|
||||
|
||||
/* Set the listening address */
|
||||
this.sockAddress = config.getGeneral().getAddress();
|
||||
/* Construct the listeners */
|
||||
constructListeners(config.getGeneral().getAddresses());
|
||||
|
||||
/* Initialize the server */
|
||||
init();
|
||||
@ -76,6 +76,34 @@ public class DServer : Thread
|
||||
startServer();
|
||||
}
|
||||
|
||||
private void constructListeners(Address[] listenAddresses)
|
||||
{
|
||||
gprintln("Constructing "~to!(string)(listenAddresses.length)~" listsners...");
|
||||
|
||||
foreach(Address listenAddress; listenAddresses)
|
||||
{
|
||||
gprintln("Constructing listener for address '"~to!(string)(listenAddress)~"'");
|
||||
|
||||
import std.socket : AddressInfo;
|
||||
AddressInfo addrInfo;
|
||||
|
||||
/* Set the address (and port) to the current one along with address family */
|
||||
addrInfo.address = listenAddress;
|
||||
addrInfo.family = listenAddress.addressFamily;
|
||||
|
||||
/* Set standard stuff */
|
||||
addrInfo.protocol = ProtocolType.TCP;
|
||||
|
||||
addrInfo.type = SocketType.STREAM;
|
||||
|
||||
/* Construct the listener */
|
||||
listeners ~= new DListener(this, addrInfo);
|
||||
gprintln("Listener for '"~to!(string)(listenAddress)~"' constructed");
|
||||
}
|
||||
|
||||
gprintln("Listener construction complete.");
|
||||
}
|
||||
|
||||
public DConfig getConfig()
|
||||
{
|
||||
return config;
|
||||
|
Loading…
Reference in New Issue
Block a user