mirror of
https://github.com/deavminet/dnetd
synced 2024-09-21 17:53:39 +02:00
Initiate outbound connetion
This commit is contained in:
parent
a10784ec99
commit
5ecb1faa19
@ -73,6 +73,10 @@ void main(string[] args)
|
||||
/* Get all server links */
|
||||
DLink[] serverLinks = linkConfig.getLinks();
|
||||
|
||||
|
||||
import std.conv : to;
|
||||
gprintln("Links I will be opening: " ~to!(string)(serverLinks));
|
||||
|
||||
/* Create a new Meyer (link manager) and attach the links to it */
|
||||
DMeyer meyer = new DMeyer(dserver, serverLinks);
|
||||
|
||||
|
@ -19,11 +19,26 @@ import core.thread : Thread;
|
||||
*/
|
||||
public final class DLinkManager
|
||||
{
|
||||
this(DServer server, DLink[] seedLinks)
|
||||
|
||||
this(DServer server)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Goes through the DConnection[] array in DServer and returns
|
||||
* all connections that are SERVER connections
|
||||
*/
|
||||
public DConnection[] getLinkedServers()
|
||||
{
|
||||
DConnection[] links;
|
||||
|
||||
/* TODO: Implement me */
|
||||
|
||||
|
||||
return links;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -63,6 +78,9 @@ public final class DLink : Thread
|
||||
/* Set the worker thread for outbound connections */
|
||||
super(&outboundWorker);
|
||||
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
|
||||
/* Create an outbound connection */
|
||||
/* TODO: Fuuuuuuuuuuuuuuuuuuuck handling of shit here bababooey and not in dconnection.d as we would have done below */
|
||||
|
||||
@ -76,7 +94,13 @@ public final class DLink : Thread
|
||||
private void initializeOutboundConnection()
|
||||
{
|
||||
/* Open a connection to the server */
|
||||
// connection = new DConnection();
|
||||
import std.socket;
|
||||
|
||||
Socket socket = new Socket(address.addressFamily, SocketType.STREAM, ProtocolType.TCP);
|
||||
socket.connect(address);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void outboundWorker()
|
||||
@ -89,6 +113,12 @@ public final class DLink : Thread
|
||||
}
|
||||
|
||||
|
||||
override public string toString()
|
||||
{
|
||||
return "Server: "~name~", Address: "~to!(string)(address);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a DLink for an inbound peering
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user