public Binding Start(IPAddress ipAddress, int port) { _socket = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.IP); _socket.Bind(new IPEndPoint(ipAddress, port)); _socket.Listen(20); _binding = new Binding(ipAddress, ((IPEndPoint)_socket.LocalEndPoint).Port); _listening = true; StartListen(); return _binding; }
protected bool Equals(Binding other) { return IpAddress.Equals(other.IpAddress) && Port == other.Port; }
public void Bind(IPAddress ipAddress, int port) { var binding = new Binding(ipAddress, port); SocketListener listener = _factory.CreateSocketListener(binding); _listeners[binding] = listener; listener.IncomingChannel += PrepareChannel; listener.Start(); }
public void Unbind(IPAddress ipAddress, int port) { var binding = new Binding(ipAddress, port); SocketListener listener; if(_listeners.TryRemove(binding, out listener)) listener.Stop(); }
public void Disconnect(IPAddress ipAddress, int port) { Task.Factory.StartNew(() => { var binding = new Binding(ipAddress, port); IChannel channel; if(_channels.TryGetValue(binding, out channel)) channel.Disconnect(); }); }
public void Connect(IPAddress ipAddress, int port) { var binding = new Binding(ipAddress, port); OutboundChannel channel = _factory.CreateOutboundChannel(binding); PrepareChannel(channel); channel.Connect(); }
public SocketListener CreateSocketListener(Binding binding) { return _container.Resolve<SocketListener>(binding); }
public OutboundChannel CreateOutboundChannel(Binding binding) { return _container.Resolve<OutboundChannel>(binding); }
public InboundChannel CreateInboundChannel(Socket socket, Binding binding) { return _container.Resolve<InboundChannel>(socket, binding); }
public SocketListener(Binding binding, HyperletterFactory factory) { _binding = binding; _factory = factory; }