internal WireBusClient(Socket socket) { _socket = socket; _semantics = new ConnectionSemantics(); ReceiveMessages(); }
internal WireBusClient(Socket socket, ConnectionSemantics semantics) { _socket = socket; _semantics = semantics; ReceiveMessages(); }
/// <summary> /// Creates a new host configured to listen on the specified IP and port /// </summary> /// <param name="address">local address</param> /// <param name="port">local port</param> /// <param name="semantics">the connection semantics</param> public WireBusListener(IPAddress address, int port, ConnectionSemantics semantics = new ConnectionSemantics()) { _semantics = semantics; _listener = new TcpListener(address, port); }
/// <summary> /// Creates a new host configured to listen on the specified IP and port /// </summary> /// <param name="endpoint">the local endpoint</param> /// <param name="semantics">the connection semantics</param> public WireBusListener(IPEndPoint endpoint, ConnectionSemantics semantics = new ConnectionSemantics()) { _semantics = semantics; _listener = new TcpListener(endpoint); }
/// <summary> /// Connect to a peer, returning a new bus. /// </summary> /// <param name="host">the target host</param> /// <param name="port">the target port</param> /// <param name="semantics">the semantics of the connection</param> /// <returns>the bus wrapping the new connection</returns> public static WireBusClient Connect(IPAddress host, int port, ConnectionSemantics semantics = new ConnectionSemantics()) { var bus = ConnectAsync(host, port); return bus.Result; }
/// <summary> /// Connect to a peer, returning a new bus. /// </summary> /// <param name="host">the target host</param> /// <param name="port">the target port</param> /// <param name="semantics">the semantics of the connection</param> /// <param name="timeout">the timeout after which to give up</param> /// <param name="token">token used to cancel connection attempt</param> /// <returns>the bus wrapping the new connection</returns> public static Task<WireBusClient> ConnectAsync(IPAddress host, int port, TimeSpan timeout, CancellationToken token, ConnectionSemantics semantics = new ConnectionSemantics()) { var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); return Task.Factory.FromAsync(socket.BeginConnect, socket.EndConnect, host, port, null) .ContinueWith(task => new WireBusClient(socket, semantics)) .NaiveTimeoutAndCancellation(timeout, token); }
/// <summary> /// Connect to a peer, returning a new bus. /// </summary> /// <param name="host">the target host</param> /// <param name="port">the target port</param> /// <param name="semantics">the semantics of the connection</param> /// <param name="token">token used to cancel connection attempt</param> /// <returns>the bus wrapping the new connection</returns> public static Task<WireBusClient> ConnectAsync(IPAddress host, int port, CancellationToken token, ConnectionSemantics semantics = new ConnectionSemantics()) { return ConnectAsync(host, port, TimeSpan.FromMilliseconds(-1), token, semantics); }
/// <summary> /// Connect to a peer, returning a new bus. /// </summary> /// <param name="host">the target host</param> /// <param name="port">the target port</param> /// <param name="semantics">the semantics of the connection</param> /// <param name="timeout">the timeout after which to give up</param> /// <returns>the bus wrapping the new connection</returns> public static Task<WireBusClient> ConnectAsync(IPAddress host, int port, TimeSpan timeout, ConnectionSemantics semantics = new ConnectionSemantics()) { return ConnectAsync(host, port, timeout, CancellationToken.None, semantics); }
/// <summary> /// Connect to a peer, returning a new bus. /// </summary> /// <param name="host">the target host</param> /// <param name="port">the target port</param> /// <param name="millisecondsTimeout">the timeout in milliseconds after which to give up</param> /// <param name="semantics">the semantics of the connection</param> /// <returns>the bus wrapping the new connection</returns> public static Task<WireBusClient> ConnectAsync(string host, int port, int millisecondsTimeout, ConnectionSemantics semantics = new ConnectionSemantics()) { return ConnectAsync(host, port, TimeSpan.FromMilliseconds(millisecondsTimeout), semantics); }
/// <summary> /// Connect to a peer, returning a new bus. /// </summary> /// <param name="host">the target host</param> /// <param name="port">the target port</param> /// <param name="semantics">the semantics of the connection</param> /// <returns>the bus wrapping the new connection</returns> public static Task<WireBusClient> ConnectAsync(string host, int port, ConnectionSemantics semantics = new ConnectionSemantics()) { return ConnectAsync(host, port, CancellationToken.None, semantics); }