예제 #1
0
        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;
        }
예제 #2
0
 protected bool Equals(Binding other)
 {
     return IpAddress.Equals(other.IpAddress) && Port == other.Port;
 }
예제 #3
0
파일: HyperSocket.cs 프로젝트: riax/Clr
        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();
        }
예제 #4
0
파일: HyperSocket.cs 프로젝트: riax/Clr
 public void Unbind(IPAddress ipAddress, int port)
 {
     var binding = new Binding(ipAddress, port);
     SocketListener listener;
     if(_listeners.TryRemove(binding, out listener))
         listener.Stop();
 }
예제 #5
0
파일: HyperSocket.cs 프로젝트: riax/Clr
 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();
                           });
 }
예제 #6
0
파일: HyperSocket.cs 프로젝트: riax/Clr
 public void Connect(IPAddress ipAddress, int port)
 {
     var binding = new Binding(ipAddress, port);
     OutboundChannel channel = _factory.CreateOutboundChannel(binding);
     PrepareChannel(channel);
     channel.Connect();
 }
예제 #7
0
 public SocketListener CreateSocketListener(Binding binding)
 {
     return _container.Resolve<SocketListener>(binding);
 }
예제 #8
0
 public OutboundChannel CreateOutboundChannel(Binding binding)
 {
     return _container.Resolve<OutboundChannel>(binding);
 }
예제 #9
0
 public InboundChannel CreateInboundChannel(Socket socket, Binding binding)
 {
     return _container.Resolve<InboundChannel>(socket, binding);
 }
예제 #10
0
파일: SocketListener.cs 프로젝트: riax/Clr
 public SocketListener(Binding binding, HyperletterFactory factory)
 {
     _binding = binding;
     _factory = factory;
 }