예제 #1
0
 public MainWindow()
 {
     InitializeComponent();
     client             = new SocketsClient();
     client.logFunction = UpdateLog;
     client.updateScreenAfterDisconnect = UpdateDisconnect;
     Port.IsEnabled       = true;
     IP.IsEnabled         = true;
     MesClient.IsEnabled  = false;
     SendClient.IsEnabled = false;
     DisConnect.IsEnabled = false;
 }
예제 #2
0
        public string localIpPort = "";              // 记录本地ip端口信息

        ////sockets
        private void ConnectService()
        {
            try
            {
                if (client == null)
                {
                    string ipString   = System.Configuration.ConfigurationManager.AppSettings["ServerIP"];
                    string portString = System.Configuration.ConfigurationManager.AppSettings["ServerPort"];
                    client = new SocketsClient(print, ipString, DataTypeConvert.ToInt32(portString, 3780));
                }
                if (!client.connected)
                {
                    client.start();
                }
                if (client != null)
                {
                    Console.WriteLine("客户端" + "" + client.localIpPort);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("客户端" + "" + ex.Message);
            }
        }