public ISocket CreateAndConnectAsync(RedFoxEndpoint endpoint, NodeType nodeType, ISocketConfiguration socketConfiguration) { switch (endpoint.Transport) { case RedFoxTransport.Inproc: return(CreateInProcSocket(endpoint)); case RedFoxTransport.Tcp: return(CreateTcpSocket(endpoint, nodeType, socketConfiguration)); default: throw new NotSupportedException(String.Format("Transport {0} not supported", endpoint.Transport)); } }
public ISocketAccepter CreateAndBind(RedFoxEndpoint endpoint, NodeType nodeType, ISocketConfiguration socketConfiguration, ClientConnectedDelegate onClientConnected = null, ClientDisconnectedDelegate onClientDisconnected = null) { if (socketConfiguration == null) { throw new ArgumentNullException("socketConfiguration"); } var server = CreateForTransport(endpoint.Transport); server.Bind(endpoint, nodeType, socketConfiguration, onClientConnected, onClientDisconnected); return(server); }
private static ISocket CreateTcpSocket(RedFoxEndpoint endpoint, NodeType nodeType, ISocketConfiguration socketConfiguration) { var hasReceiveTimeout = NodeTypeHasReceiveTimeout.HasReceiveTimeout(nodeType); var tcpClient = new TcpClient { ReceiveTimeout = hasReceiveTimeout ? socketConfiguration.ReceiveTimeout.ToMillisOrZero() : 0, SendTimeout = socketConfiguration.SendTimeout.ToMillisOrZero(), NoDelay = true, ReceiveBufferSize = socketConfiguration.ReceiveBufferSize, SendBufferSize = socketConfiguration.SendBufferSize }; ConnectTcpSocket(tcpClient, endpoint.Host, endpoint.Port, socketConfiguration.ConnectTimeout); return(new TcpSocket(endpoint, tcpClient)); }
private static ISocket CreateInProcSocket(RedFoxEndpoint endpoint) { return(InProcessEndpoints.Instance.Connect(endpoint)); }