Exemplo n.º 1
0
        void TCP_Listener()
        {
            receiver = new RecSock(svrIP, svrPort);  //shouldn't new up each loop

            while (true)
            {
                try
                {
                    string retstr = null;

                    receiver.AcceptAConnection();

                    GlobSyn.Log("Waiting for connected client to talk to: " + receiver.connEndPoint.ToString());
                    //stall on first message - WHAT IS YOUR PURPOSE HERE, SON?!  IDENTIFY YOURSELF
                    do
                    {
                        retstr = receiver.ReceiveWholeMsg();
                    } while (retstr == null);
                    //HERE tell parent to set up connection to client's server
                    //_synch.Invoke(parentThread.TakeThisLogMsg, new object[1] { "Initial Message received from client " + receiver.remEP.ToString() });

                    GlobSyn.Log("Initial Message received from client " + receiver.remEP.ToString());


                    try
                    {
                        TCPClientConn temp = new TCPClientConn(receiver.handler, cType);
                        temp.SelfDestruct += new ClientKiller(MuderThatClientAtHisBehest);
                        clients.Add(temp); //starts a new threaded conversation
                    }
                    catch (Exception exIn)
                    {
                        GlobSyn.Log("FAILED trying to start TCP Client Connection thread" + Environment.NewLine + "~~See Exception: " + exIn.Message);
                    }
                }
                catch (Exception ex)
                {
                    GlobSyn.Log("FAILED TCP Listener " + receiver.connEndPoint.ToString() + " has crashed" + Environment.NewLine + "~~See Exception: " + ex.Message);
                }
            }
        }
Exemplo n.º 2
0
 private void MuderThatClientAtHisBehest(TCPClientConn conn)
 {
     //taking the object out of any scope should get her good and garbage collected...eventually >.V  hopefully the thread actually stopped
     clients.Remove(conn);
     conn = null;
 }