示例#1
0
        public VncClient(string serverHost, ushort listenerPort)
            : base(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
        {
            ListenerPortOfServer = listenerPort;
            this.serverHost      = serverHost;

            ReceiveTimeout = Constants.SOCKET_CONNECTION_TIMEOUT;
            SendTimeout    = Constants.SOCKET_CONNECTION_TIMEOUT;
            SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, Constants.MAX_BUFFER_SIZE);
            SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, Constants.MAX_BUFFER_SIZE);

            LingerState  = new LingerOption(true, 1);
            NoDelay      = true;
            DontFragment = true;

            var  result  = BeginConnect(this.serverHost, ListenerPortOfServer, null, null);
            bool success = result.AsyncWaitHandle.WaitOne(Constants.SOCKET_CONNECTION_TIMEOUT, true);

            if (!success)
            {
                ErrorBox.Show("Unable to connect", "Check if VNC server is running, check the service port and the firewall settings");
            }
            else
            {
                DataArrived += new DataArrivedEventHandler(DataArrivedHandler);
                Task.Factory.StartNew(() => { Receiver(); });
            }
        }
示例#2
0
 public void SetNewDataArriveEventHandler(DataArrivedEventHandler dataArrivedEventHandler)
 {
     if (dataArrivedEventHandler != null)
     {
         DataArrived -= DataArrivedHandler;
         DataArrived += dataArrivedEventHandler;
     }
 }
 protected ClientBase(string serverHostnameOrIpAddress, DataArrivedEventHandler dataArrived, ushort listenerPortOfServer)
 {
     Encoding                  = Encoding.UTF8;
     Socket                    = null;
     ListenerPortOfServer      = listenerPortOfServer;
     buffer                    = new byte[MaxBufferSize];
     ServerHostnameOrIpAddress = serverHostnameOrIpAddress;
     DataArrived               = dataArrived;
 }
        private static void DataArrivedDeleteAdd(int devhandle, string ip, DataArrivedEventHandler onDataArrivedEvent)
        {
            DataArrivedDeleteInfo item = new DataArrivedDeleteInfo {
                devHandle          = devhandle,
                ip                 = ip,
                OnDataArrivedEvent = onDataArrivedEvent
            };

            lsDataArrivedDeleteInfo.Add(item);
        }
        public ServerSocket(int listenerPort)
            : base(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
        {
            working = true;
            ListenerPortOfServer = listenerPort;

            Bind(new IPEndPoint(IPAddress.Any, listenerPort));
            Listen(MAX_PENDING_CONNECTION);
            DataArrived += new DataArrivedEventHandler(DataArrivedHandler);
            Task.Factory.StartNew(() => { ListenerEngine(); });
        }
示例#6
0
 private void Send(string message, DataArrivedEventHandler vncClientDataArrived = null)
 {
     try
     {
         var vncClient = new VncClient(cb_Computer.Text, Constants.VNC_PORT);
         vncClient.SetNewDataArriveEventHandler(vncClientDataArrived);
         vncClient.Send(message);
     }
     catch (Exception ex)
     {
         ErrorBox.Show("MainForm.Send", ex);
     }
 }
示例#7
0
        public VncServer(int listenerPort = 0)
            : base(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
        {
            working = true;
            ListenerPortOfServer = listenerPort;
            if (listenerPort == 0)
            {
                listenerPort = PortUtils.GetFreePort();
            }

            Bind(new IPEndPoint(IPAddress.Any, listenerPort));
            Listen(Constants.MAX_PENDING_CONNECTION);
            DataArrived += new DataArrivedEventHandler(DataArrivedHandler);
            Task.Factory.StartNew(() => { ListenerEngine(); });
            Task.Factory.StartNew(() => { ScreenSender(); });
        }
 public SnmpClient(string serverHostnameOrIpAddress, DataArrivedEventHandler dataArrived)
     : base(serverHostnameOrIpAddress, dataArrived, (ushort)ClientType.SNMP)
 {
 }
示例#9
0
 /// <summary>
 /// <see href="https://tools.ietf.org/html/rfc821">RFC-821</see>
 /// </summary>
 /// <param name="serverHostOrIp"></param>
 /// <param name="dataArrivedHandler"></param>
 public SmtpClient(string serverHostOrIp, DataArrivedEventHandler dataArrivedHandler)
     : base(serverHostOrIp, dataArrivedHandler, (ushort)ClientType.SMTP)
 {
 }
 /// <summary>
 /// <see href="https://www.ietf.org/rfc/rfc959.txt">RFC-959</see>
 /// </summary>
 /// <param name="serverHostnameOrIpAddress"></param>
 /// <param name="dataArrived"></param>
 /// <param name="fileDataArrived"></param>
 public FtpClient(string serverHostnameOrIpAddress, DataArrivedEventHandler dataArrived,
                  DataArrivedEventHandler fileDataArrived)
     : base(serverHostnameOrIpAddress, dataArrived, (ushort)ClientType.FTP_CONTROL)
 {
     FileDataArrived = fileDataArrived;
 }