Exemplo n.º 1
0
 public TcpTalk(TcpClient client)
 {
     var ipAddress = ((IPEndPoint)client.Client.RemoteEndPoint).Address;
     var port = ((IPEndPoint)client.Client.RemoteEndPoint).Port;
     Destination = new TcpAddress(ipAddress, port);
     _client = client;
     _client.LingerState.Enabled = false;
     ReadFromStream();
 }
Exemplo n.º 2
0
        public TcpTalk(int port, TcpAddress destination)
        {
            Destination = destination;

            var ipLocalEndPoint = new IPEndPoint(GetIpAddress(), port);
            _client = new TcpClient(ipLocalEndPoint);
            _client.LingerState.Enabled = false;
            _client.Connect(destination.Host, destination.Port);
            ReadFromStream();
        }
Exemplo n.º 3
0
 private TcpTalk GetTalker(string connectionId, TcpAddress destination)
 {
     lock (_talkers)
     {
         TcpTalk talker;
         if (!_talkers.TryGetValue(connectionId, out talker))
         {
             talker = new TcpTalk(_port, destination);
             talker.HandleMessage(HandleMessage);
             _talkers[connectionId] = talker;
         }
         return talker;
     }
 }