示例#1
0
        private void ConnectionSes()
        {
            Socket soc = null;

            try
            {
                soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                soc.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
                soc.Bind(IPPDlocal);

                SendStatus($"Соединение с {IPPDremote}");

                soc.Connect(IPPDremote);
                if (registration(soc))
                {
                    Dispatcher.Invoke(() =>
                    {
                        SessionW sw = new SessionW(TM, soc, remdevName, remdevGuid);
                        sw.Show();
                    });
                }
            }
            catch (Exception e)
            {
                SendStatus(e.Message, ConsoleColor.Red);
                Protocol.ProtectedCloseSocket(soc);
            }
            Dispatcher.Invoke(() => Close());
        }
示例#2
0
 public SessionModel(SessionW sw, Socket c, string remName, byte[] remotelGuid)
 {
     AddSessions(this);
     remoteName     = remName;
     _SessionW      = sw;
     _SessionClient = new SessionClient(c, this, remotelGuid);
     baseClient     = _SessionClient;
 }