public void Connect(bool runReceiveThreadWhenConnected)
        {
            releaseThreads();


            _queue.Clear();

            //if((_thread!=null && _thread.ThreadState == ThreadState.Running) || this.isConnected()) Disconnect();
            int       id   = _threadId;
            UdpClient conn = new UdpClient();

            _clients.Add(id, conn);
            _queue.Clear();//이전 것은 의미가 없으므로 다시 큐를 비워줌..

            if (_sendType == SendType.Normal)
            {
                //_uSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                conn.Connect(_serverIp, _serverPort);

                //_uSocket.Bind(_localEP);
            }
            else if (_sendType == SendType.Multicast)
            {
                conn.Connect((IPEndPoint)_remoteEP);
                conn.JoinMulticastGroup(NetFunctions.getIP4Address(_serverIp), NetFunctions.getMyIP4Address());

                //_uSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                //_uSocket.Bind(_localEP);
                //_uSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse(server)));
            }
            else //broadcast
            {
                conn.Connect((IPEndPoint)_remoteEP);
                conn.Client.Bind(_localEP);
                conn.Client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.Broadcast, true);
            }
            _isConnected = true;
            if (runReceiveThreadWhenConnected)
            {
                runRecvThread();
            }
        }
        public void setServerInfo(string server, int port, int readTimeout = 0, int writeTimeout = 0)
        {
            _readTimeout  = readTimeout;
            _writeTimeout = writeTimeout;
            _serverIp     = server;
            _serverPort   = port;

            //_isEndConnection = false;
            _localEP = new IPEndPoint(NetFunctions.getMyIP4Address(), IPEndPoint.MinPort + 1); //this is blank IPEndPoint yet.
            //_localEP = new IPEndPoint(IPAddress.None, port); //this is blank IPEndPoint yet.

            if (server != null && server.Length > 7)
            {
                _remoteEP = new IPEndPoint(NetFunctions.getIP4Address(_serverIp), _serverPort);
            }
            else
            {
                _remoteEP = new IPEndPoint(NetFunctions.getMyIP4Address(), _serverPort);
            }


            //            setServer(server, port, null, readTimeout, writeTimeout);
        }
        /// <summary>
        /// 서버의 정보를 적는다.
        /// 바로 받는 루틴을 시작하지는 않는다.
        /// </summary>
        /// <param name="server"></param>
        /// <param name="port"></param>
        /// <param name="isUsingReceiveQueue"></param>
        /// <param name="saveFile"></param>
        /// <param name="readTimeout"></param>
        /// <param name="writeTimeout"></param>
        public void setServerInfo(string server, int port, int readTimeout = 0, int writeTimeout = 0)
        {
            if (_listener != null)
            {
                return;
            }

            _isEndServer = false;

            IPEndPoint ipe;

            if (server != null && server.Length > 7)
            {
                ipe = new IPEndPoint(NetFunctions.getIP4Address(server), port);
            }
            else
            {
                ipe = new IPEndPoint(NetFunctions.getMyIP4Address(), port);
            }
            _listener = new TcpListener(ipe);
            _listener.Start();

            //            setServer(server, port, null, readTimeout, writeTimeout);
        }