예제 #1
0
 public static OnlineCommands GetOnlineCommand(System.Net.EndPoint endPoint, string com, int hashcode)
 {
     try
     {
         OnlineCommands commands = null;
         using (var db = new LiteDatabase(Environment.CurrentDirectory + "/data.db"))
         {
             var col  = db.GetCollection <OnlineCommands>("onlinecommands");
             var coms = col.FindAll().AsQueryable()
                        .Where(x => x.IP == endPoint.ToString().Split(':')[0] &&
                               x.Port == endPoint.ToString().Split(':')[1] &&
                               x.HashCode == hashcode &&
                               x.Command == com)
                        .Select(x => x).ToList();
             if (coms.Count() > 0)
             {
                 commands = coms[coms.Count() - 1];
             }
             return(commands);
         }
     }
     catch (Exception) {
         return(null);
     }
 }
예제 #2
0
 public static OnlineCommands InsertOnlineCommand(System.Net.EndPoint endPoint, string com, int hashcode)
 {
     try
     {
         using (var db = new LiteDatabase(Environment.CurrentDirectory + "/data.db"))
         {
             var col     = db.GetCollection <OnlineCommands>("onlinecommands");
             var command = new OnlineCommands
             {
                 IP       = endPoint.ToString().Split(':')[0],
                 Port     = endPoint.ToString().Split(':')[1],
                 HashCode = hashcode,
                 Command  = com,
                 Result   = string.Empty,
                 Error    = string.Empty,
                 Status   = false
             };
             col.Insert(command);
             return(command);
         }
     }
     catch (Exception ex) {
         return(null);
     }
 }
예제 #3
0
        public string ClientAddress()
        {
            if (sessionType == SessionTypeEnum.Server)
            {
                return(String.Empty);
            }
            Hashtable transportCollectionClone = talkerConnectionListener.GetTransportCollectionClone();

            if (transportCollectionClone.Count != 1)
            {
                if (transportCollectionClone.Count != 1)
                {
                    return(String.Empty);
                }
            }
            foreach (DictionaryEntry de in transportCollectionClone)
            {
                ITransport transport = (ITransport)de.Value;
                if (transport == null)
                {
                    return(String.Empty);
                }
                System.Net.Sockets.Socket socket   = ((Transport)transport).getSocket();
                System.Net.EndPoint       endPoint = socket.LocalEndPoint;
                return(endPoint.ToString());
            }
            return(String.Empty);
        }
예제 #4
0
        public static SipMessage RSPInvitePacket(SipMessage packet)
        {
            System.Net.EndPoint localPoint = Ower.Conncetion.LocalEndPoint;
            string port = localPoint.ToString().Split(':')[1];

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("v=0");
            sb.AppendLine("o=-0 0 IN " + localPoint.ToString());
            sb.AppendLine("s=session");
            sb.AppendLine("c=IN IP4 " + localPoint.ToString());
            sb.AppendLine("t=0 0");
            sb.AppendLine(string.Format("m=message {0} sip {1}", port, Ower.Uri.Sid));
            SipResponse response = CreateDefaultResponse(packet);

            response.Body = sb.ToString();
            return(response);
        }
예제 #5
0
 public ConnectionInfo GetConnectionInfo()
 {
     return(new ConnectionInfoBuilder {
         ProtocolName = "RTMP Output",
         Type = ConnectionType.Direct,
         Status = ConnectionStatus.Connected,
         RemoteName = remoteEndPoint.ToString(),
         RemoteEndPoint = remoteEndPoint as System.Net.IPEndPoint,
         RemoteHostStatus = RemoteHostStatus.Receiving,
         ContentPosition = connection.ContentPosition,
         RecvRate = (float)this.inputStream.ReadRate,
         SendRate = (float)this.outputStream.WriteRate,
         AgentName = connection.ClientName
     }.Build());
 }
예제 #6
0
 public void SetSourceEndpoint(System.Net.EndPoint remoteEndpoint)
 {
     try
     {
         this.PrimaryKey     = System.Guid.NewGuid();
         this.SourceEndpoint = remoteEndpoint.ToString();
         System.Net.IPEndPoint ipEndPoint = remoteEndpoint as System.Net.IPEndPoint;
         this.SourceIP   = ipEndPoint.Address.ToString();
         this.SourceHost = System.Net.Dns.GetHostEntry(ipEndPoint.Address).HostName;
     }
     catch (System.Exception ex)
     {
         this.EndpointException = ex;
     }
 }
예제 #7
0
        static void Main(string[] args)
        {
            int Port = 5150;

            try
            {
                System.Net.IPAddress IPAddress;

                IPAddress = System.Net.IPAddress.Any;

                System.Net.IPEndPoint LocalEP = new System.Net.IPEndPoint(IPAddress, Port);

                System.Net.Sockets.Socket ReceivingSocket = new System.Net.Sockets.Socket(
                    System.Net.Sockets.AddressFamily.InterNetwork,
                    System.Net.Sockets.SocketType.Dgram,
                    System.Net.Sockets.ProtocolType.Udp);

                ReceivingSocket.Bind(LocalEP);

                System.Console.WriteLine("Waiting for data...");

                byte [] buffer = new byte[1024];

                System.Net.IPAddress  RemoteIPAddress  = System.Net.IPAddress.Any;
                System.Net.IPEndPoint RemoteIPEndPoint = new System.Net.IPEndPoint(
                    RemoteIPAddress, 0);
                System.Net.SocketAddress RemoteAddress = new System.Net.SocketAddress(
                    System.Net.Sockets.AddressFamily.InterNetwork);
                System.Net.EndPoint RefRemoteEP = RemoteIPEndPoint.Create(RemoteAddress);

                int BytesReceived = ReceivingSocket.ReceiveFrom(buffer, ref RefRemoteEP);

                System.Console.WriteLine("Successfully received " +
                                         BytesReceived.ToString() + " byte(s) from " +
                                         RefRemoteEP.ToString());

                ReceivingSocket.Close();
            }

            catch (System.Net.Sockets.SocketException err)
            {
                Console.WriteLine("Error: " + err.Message);
            }
        }
예제 #8
0
        void OnData(IAsyncResult _asyncResult)
        {
            var Client = _asyncResult.AsyncState as TelnetClient;

            System.Net.EndPoint remoteEndPoint = null;

            if (Client.Socket == null)
            {
                if (!Client.WasRejected)
                {
                    Clients.ClientDisconnected(Client);
                }
                return;
            }

            try
            {
                remoteEndPoint = Client.Socket.RemoteEndPoint;
            }
            catch (Exception) //Just shut this one up.
            {
                if (!Client.WasRejected)
                {
                    Clients.ClientDisconnected(Client);
                }
                return;
            }

            try
            {
                System.Net.Sockets.SocketError Error;
                int DataSize = Client.Socket.EndReceive(_asyncResult, out Error);

                if (DataSize == 0 || Error != System.Net.Sockets.SocketError.Success)
                {
                    if (remoteEndPoint != null)
                    {
                        Console.WriteLine("Lost telnet client: " + remoteEndPoint.ToString());
                    }
                    else
                    {
                        Console.WriteLine("Lost telnet client: Unknown remote endpoint.");
                    }

                    if (!Client.WasRejected)
                    {
                        Clients.ClientDisconnected(Client);
                    }
                }
                else
                {
                    for (int i = 0; i < DataSize; ++i)
                    {
                        var character = (char)Client.Storage[i];

                        if (character == '\n' || character == '\r')
                        {
                            //if (Client.Echo == Echo.All || Client.Echo == Echo.Mask)
                            //{
                            //    Client.Send(new byte[] { (byte)character });
                            //}

                            if (!String.IsNullOrEmpty(Client.CommandQueue))
                            {
                                String Command = Client.CommandQueue;
                                Client.CommandQueue = "";
                                RMUD.Core.EnqueuActorCommand(Client.Player, Command);
                            }
                        }
                        else if (character == '\b')
                        {
                            if (Client.CommandQueue.Length > 0)
                            {
                                Client.CommandQueue = Client.CommandQueue.Remove(Client.CommandQueue.Length - 1);
                                //if (Client.Echo == Echo.All || Client.Echo == Echo.Mask)
                                //{
                                //    Client.Send(new byte[] { (byte)character });
                                //}
                            }
                        }
                        else if (ValidCharacters.Contains(character))
                        {
                            Client.CommandQueue += character;
                            //switch (Client.Echo)
                            //{
                            //    case Echo.All: Client.Send(new byte[] { (byte)character }); break;
                            //    case Echo.Mask: Client.Send(new byte[] { (byte)'*' }); break;
                            //    case Echo.None: break;
                            //}
                        }
                    }

                    Client.Socket.BeginReceive(Client.Storage, 0, 1024, System.Net.Sockets.SocketFlags.Partial, OnData, Client);
                }
            }
            catch (Exception e)
            {
                if (remoteEndPoint != null)
                {
                    Console.WriteLine("Lost telnet client: " + remoteEndPoint.ToString());
                }
                else
                {
                    Console.WriteLine("Lost telnet client: Unknown remote endpoint.");
                }
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                if (!Client.WasRejected)
                {
                    Clients.ClientDisconnected(Client);
                }
            }
        }
예제 #9
0
 internal static string GetConnectIdent(System.Net.EndPoint endpoint)
 {
     return(GetAuditTimestamp() + " " + (endpoint == null ? "??connect??" : endpoint.ToString()));
 }
예제 #10
0
        public static bool PingHost(string host)
        {
            //Declare the IPHostEntry

            System.Net.IPHostEntry serverHE, fromHE;
            int nBytes = 0;
            int dwStart = 0, dwStop = 0;

            //Initilize a Socket of the Type ICMP
            System.Net.Sockets.Socket socket     = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork,
                                                                                 System.Net.Sockets.SocketType.Raw, System.Net.Sockets.ProtocolType.Icmp);
            // Get the server endpoint
            try
            {
                //serverHE = System.Net.Dns.GetHostByName(host);
                serverHE = System.Net.Dns.GetHostEntry(host);
            }
            catch (Exception)
            {
                errorstring = "未找到主机";
                //Console.WriteLine("Host not found"); // fail
                return(false);
            }
            // Convert the server IP_EndPoint to an
            //     EndPoint
            System.Net.IPAddress  ipbind         = null;
            System.Net.IPEndPoint ipepServer     = new System.Net.IPEndPoint(System.Net.IPAddress.Parse(host), 0);
            System.Net.EndPoint   epServer       = (ipepServer);
            // Set the receiving endpoint to the cli
            //     ent machine
            //fromHE = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName());
            fromHE = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
            foreach (System.Net.IPAddress ip in fromHE.AddressList)
            {
                if (System.Net.Sockets.AddressFamily.InterNetwork.Equals(ip.AddressFamily))
                {
                    ipbind = ip;
                    break;
                }
            }
            System.Net.IPEndPoint ipEndPointFrom = new System.Net.IPEndPoint(ipbind, 0);
            System.Net.EndPoint   EndPointFrom   = (ipEndPointFrom);
            int        PacketSize                = 0;
            IcmpPacket packet                    = new IcmpPacket();

            // Construct the packet to send
            packet.Type           = ICMP_ECHO; //8
            packet.SubCode        = 0;
            packet.CheckSum       = UInt16.Parse("0");
            packet.Identifier     = UInt16.Parse("45");
            packet.SequenceNumber = UInt16.Parse("0");
            int PingData = 32; // sizeof(IcmpPacket) - 8;

            packet.Data = new Byte[PingData];
            //Initilize the Packet.Data
            for (int i = 0; i < PingData; i++)
            {
                packet.Data[i] = (byte)'#';
            }
            //Variable to hold the total Packet size
            //
            PacketSize = PingData + 8;
            Byte[] icmp_pkt_buffer = new Byte[PacketSize];
            Int32  Index           = 0;

            //Call a Methos Serialize which counts
            //The total number of Bytes in the Packe
            //     t
            Index = Serialize(
                packet,
                icmp_pkt_buffer,
                PacketSize,
                PingData);
            //Error in Packet Size
            if (Index == -1)
            {
                Console.WriteLine("Error in Making Packet");
                errorstring = "创建封包错误";
                return(false);
            }
            // now get this critter into a UInt16 ar
            //     ray
            //Get the Half size of the Packet
            Double double_length       = Convert.ToDouble(Index);
            Double dtemp               = System.Math.Ceiling(double_length / 2);
            int    cksum_buffer_length = Convert.ToInt32(dtemp);

            //Create a Byte Array
            UInt16[] cksum_buffer = new UInt16[cksum_buffer_length];
            //Code to initilize the Uint16 array
            int icmp_header_buffer_index = 0;

            for (int i = 0; i < cksum_buffer_length; i++)
            {
                cksum_buffer[i] =
                    BitConverter.ToUInt16(icmp_pkt_buffer, icmp_header_buffer_index);
                icmp_header_buffer_index += 2;
            }
            //Call a method which will return a chec
            //     ksum
            UInt16 u_cksum = checksum(cksum_buffer, cksum_buffer_length);

            //Save the checksum to the Packet
            packet.CheckSum = u_cksum;
            // Now that we have the checksum, serial
            //     ize the packet again
            Byte[] sendbuf = new Byte[PacketSize];
            //again check the packet size
            Index = Serialize(
                packet,
                sendbuf,
                PacketSize,
                PingData);
            //if there is a error report it
            if (Index == -1)
            {
                Console.WriteLine("Error in Making Packet");
                errorstring = "添加校验码后的封包错误";
                return(false);
            }
            dwStart = System.Environment.TickCount; // Start timing
            Console.WriteLine(dwStart.ToString());
            //send the Pack over the socket

            if ((nBytes = socket.SendTo(sendbuf, PacketSize, 0, epServer)) == SOCKET_ERROR)
            {
                Console.WriteLine("Socket Error cannot Send Packet");
                errorstring = "SendTo方法失败";
                return(false);
            }


            // Initialize the buffers. The receive b
            //     uffer is the size of the
            // ICMP header plus the IP header (20 by
            //     tes)
            Byte[] ReceiveBuffer = new Byte[256];
            nBytes = 0;
            //Receive the bytes
            bool recd    = false;
            int  timeout = 0;

            //loop for checking the time of the serv
            //     er responding
            while (!recd)
            {
                socket.ReceiveTimeout = pingtimeout;

                try
                {
                    nBytes = socket.ReceiveFrom(ReceiveBuffer, 256, 0, ref EndPointFrom);
                    Console.WriteLine(nBytes.ToString());
                    if (nBytes == SOCKET_ERROR)
                    {
                        //Console.WriteLine("Host not Responding");
                        errorstring = "主机没有响应";
                        recd        = true;
                        return(false);
                    }
                    else if (nBytes > 0)
                    {
                        dwStop = System.Environment.TickCount - dwStart; // stop timing
                        Console.WriteLine("Reply from " + epServer.ToString() + " in " + dwStop + "ms => Bytes Received: " + nBytes);
                        recd = true;
                        return(true);
                    }
                    timeout = System.Environment.TickCount - dwStart;
                    Console.WriteLine(timeout.ToString());
                    //if (timeout > 1000)
                    //{
                    //    Console.WriteLine("Time Out");
                    //    recd = true;
                    //    return false;
                    //}
                }
                catch (Exception ex)
                {
                    if (Global.IsShowBug)
                    {
                        System.Windows.Forms.MessageBox.Show(ex.Message);
                    }
                    errorstring = ex.Message;
                    return(false);
                }
            }
            //close the socket
            socket.Close();
            return(false);
        }
        public override void OnReceived(System.Net.EndPoint endpoint, byte[] buffer, long offset, long size)
        {
            bool   octetCounting = false;
            bool   isRfc5424     = false;
            bool   isRfc3164     = false;
            string rawMessage    = null;

            try
            {
                rawMessage = System.Text.Encoding.UTF8.GetString(buffer, (int)offset, (int)size);
                System.Console.WriteLine("Incoming: " + rawMessage);

                if (string.IsNullOrWhiteSpace(rawMessage))
                {
                    return;
                }

                string message = rawMessage.TrimStart();


                if (IsNumber(message))
                {
                    return; // Discard - this is just the length of a message
                }
                // rfc_5424_octet_counting: "218 <134>1 2021-09-16T21:44:22.395060+02:00 DESKTOP-6CN7QMR TestSerilog 31308 - [meta MessageNumber="2" AProperty="0.8263707183424247"] TCP: This is test message 00002
                // rfc_5424_nontransparent_framing: "<134>1 2021-09-16T21:44:22.395060+02:00 DESKTOP-6CN7QMR TestSerilog 31308 - [meta MessageNumber="2" AProperty="0.8263707183424247"] TCP: This is test message 00002

                // rfc_3164_octet_counting: "218 <30>Oct
                // rfc_3164_nontransparent_framing: "<30>Oct

                //  p = ((int)facility * 8) + (int)severity;
                // ==> severity = p % 8
                // ==> faciliy = p \ 8

                // Probe octet-framing and message-type
                // Let's do this WITHOUT regex - for speed !
                int ind = message.IndexOf('<');
                if (ind != 0)
                {
                    if (ind != -1)
                    {
                        octetCounting = true;
                        string octet = message.Substring(0, ind - 1);
                        octet = octet.TrimEnd(trimChars);
                        if (!IsNumber(octet))
                        {
                            throw new System.IO.InvalidDataException("Invalid octet framing ! \r\nMessage: " + rawMessage);
                        }

                        message = message.Substring(ind);
                    }
                    else
                    {
                        throw new System.IO.InvalidDataException(rawMessage);
                    }
                }

                int closeAngleBracketIndex = message.IndexOf('>');
                if (closeAngleBracketIndex != -1)
                {
                    closeAngleBracketIndex++;
                    string messageContent = message.Substring(closeAngleBracketIndex);
                    messageContent = messageContent.TrimStart(trimChars);
                    System.Console.WriteLine(messageContent);

                    if (messageContent.Length > 0)
                    {
                        if (char.IsDigit(messageContent[0]))
                        {
                            isRfc5424 = true;
                        }
                        else
                        {
                            isRfc3164 = true;
                        }
                    }
                    else
                    {
                        throw new System.IO.InvalidDataException(rawMessage);
                    }
                }
                else
                {
                    throw new System.IO.InvalidDataException(rawMessage);
                }


                System.Console.WriteLine("Octet counting: {0}", octetCounting);

                if (isRfc5424)
                {
                    System.Console.WriteLine("rfc_5424");
                    Rfc5424SyslogMessage msg5424 = Rfc5424SyslogMessage.Parse(message);
                    msg5424.SetSourceEndpoint(endpoint);
                    System.Console.WriteLine(msg5424);
                }
                else if (isRfc3164)
                {
                    System.Console.WriteLine("rfc_3164");
                    Rfc3164SyslogMessage msg3164 = Rfc3164SyslogMessage.Parse(message);
                    msg3164.RemoteIP = endpoint.ToString();
                    System.Console.WriteLine(msg3164);
                }
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Console.WriteLine(ex.StackTrace);

                // bool octetCounting = false;

                if (isRfc5424)
                {
                    Rfc5424SyslogMessage msg5424 = Rfc5424SyslogMessage.Invalid(rawMessage, ex);
                }
                else if (isRfc3164)
                {
                    Rfc3164SyslogMessage msg3164 = Rfc3164SyslogMessage.Invalid(rawMessage, ex);
                }
                else
                {
                }
            }
        }
예제 #12
0
 public ViewInfo(System.Net.EndPoint ip, string top = "", string end = "")
 {
     this.Text = top + "客户端:" + ip.ToString() + "\r\n" + end;
 }
예제 #13
0
 void Server_clientSendData(byte[] data, System.Net.EndPoint client)             // Testing
 {
     Console.Write(client.ToString().PadRight(18));
     Console.Write(Network.Server.getCommandType(Encoding.ASCII.GetString(data)).ToString().PadRight(15));
     Console.WriteLine(Network.Server.getCommand(Encoding.ASCII.GetString(data)));
 }
예제 #14
0
 public static void RerouteBAOOToProxy(AppConfig AppConfig, System.Net.EndPoint ProxyEndPoint)
 {
     try
     {
         System.IO.File.WriteAllText(System.IO.Path.Combine(AppConfig.BAOInstallationFolder, Constants.FileData.OnlineDefaultWBIDVarsPath), string.Format(Constants.NewData.SF_NewOnlineDefaultWBIDVarsContent, ProxyEndPoint.ToString()));
     }
     catch
     {
         throw;
     }
 }
예제 #15
0
        /// <summary>
        /// 处理接收来的TCP通讯数据,获取ID
        /// </summary>
        /// <param name="e"></param>
        /// <returns>返回的ID是 管理试验的ID,注意!不是索引</returns>
        private int MakeDataTCP(NetEventArgs e)
        {
            int ID = -1;

            //默认不知道对应我们的  哪行数据ID,先查一下SESSION,看看有没有。有就可以直接用了。
            //没有进行对比ID操作,进行匹配,数据长度也能获取到,依据配置文件
            //如果还是没有,就中断此链接
            System.Net.EndPoint remote = e.Client.ClientSocket.RemoteEndPoint;
            bool canFindEndPoint       = false;

            for (int i = 0; i < YingHeXinList.Count; i++)
            {
                if (string.Format("{0}:{1}", YingHeXinList[i].Remote_IP == null ? "0.0.0.0" : YingHeXinList[i].Remote_IP, YingHeXinList[i].Remote_Port) == remote.ToString())
                {
                    //找到了
                    canFindEndPoint = true;
                    ID = YingHeXinList[i].ID;
                    break;
                }
            }
            if (canFindEndPoint)
            {
                //找到了
            }
            else
            {
                //没找到
                //int id = e.Client.RecvDataBuffer[0];//通讯协议规定,第一个字节就是程序发出的ID指令。这个ID对应管理服务的0-200个可复用试验接口台。【注意,不是索引!】
                int id = Convert.ToInt32(PublicClassRule.MakeOneData("double", 0, e.Client.RecvDataBuffer));

                bool canFindID = false;
                for (int i = 0; i < YingHeXinList.Count; i++)
                {
                    if (YingHeXinList[i].ID == id)
                    {
                        //找到了,EndPoint绑定进去
                        canFindID = true;
                        //YingHeXinList[i].RemoteEndPoint = remote;//不知道为什么,此行注释的不行,程序中可以,但到了wcf,客户端收不到。
                        YingHeXinList[i].Remote_IP    = ((System.Net.IPEndPoint)remote).Address.ToString();
                        YingHeXinList[i].Remote_Port  = ((System.Net.IPEndPoint)remote).Port;
                        YingHeXinList[i].TCP_OK_Start = DateTime.Now;
                        ID = YingHeXinList[i].ID;
                        YingHeXinList[i].Status           = ShiYanStatus.Running;
                        YingHeXinList[i].Tcp_TimeOut_Test = new TimeOutPlay();
                        YingHeXinList[i].Web_TimeOut_Test = new TimeOutPlay();
                        break;
                    }
                }
                if (canFindID)
                {
                    //找到了,数据绑定进去,哦上面EndPoint已经写入了
                }
                else
                {
                    //没找到,关闭此链接
                    e.Client.Close();
                }
            }

            return(ID);
        }
예제 #16
0
 public new string ToString() => $"{mUUID} {mName} {mEndPoint.ToString()}";
예제 #17
0
 public static void ConnectionException(System.Net.EndPoint endpoint)
 {
     throw new Exception("Cant connect to endpoint: " + endpoint.ToString()); // TODO: custom excention
 }
예제 #18
0
        ///// <summary>
        ///// Use this to ensure access to form controls is thread safe.
        ///// Sets statusBar1.Text and timerPollCameraInterface.Enabled.
        ///// </summary>
        ///// <param name="text"></param>
        ///// <param name="enable"></param>
        //private void UpdateFormCamerasStarted(string text,bool enable)
        //{
        //    if (this.statusBar1.InvokeRequired)
        //    {
        //        UpdateFormCamerasStartedCallback d = new UpdateFormCamerasStartedCallback(UpdateFormCamerasStarted);
        //        this.Invoke(d, new object[] { text,enable });
        //    }
        //    else
        //    {
        //    //put required actions here
        //        this.statusBar1.Text = text;
        //        timerPollCameraInterface.Enabled = enable;
        //    }
        //}

        //private void UpdateStatusBarServerStarted(int portNumber)
        //{
        //    if (this.statusBar1.InvokeRequired)
        //    {
        //        UpdateStatusBarServerServerStartedCallback d = new UpdateStatusBarServerServerStartedCallback(UpdateStatusBarServerStarted);
        //        this.Invoke(d, new object[] { portNumber });
        //    }
        //    else
        //    {
        //        //put required actions here
        //        this.statusBar1.Text = ("Waiting for Connection on Port: " + portNumber.ToString());
        //    }
        //}

        void TCPServer_ClientConnectionAcceptedEvent(System.Net.EndPoint clientConnection)
        {
            UpdateStatusBar("Connected to client: " + clientConnection.ToString());
        }