Beispiel #1
0
        public void onClientConnect(IAsyncResult asyn)
        {
            try
            {

                int Empty_chennelID = -1;
                Socket temp_sock = MainSocket.EndAccept(asyn);
                Empty_chennelID = findEmptyChennel();
                if (Empty_chennelID != -1)
                {
                    WorkSocket[Empty_chennelID] = temp_sock;
                    temp_sock = null;
                }
                SocketState socketstate = new SocketState();
                socketstate.m_currentSocket = WorkSocket[Empty_chennelID];
                WorkSocket[Empty_chennelID].BeginReceive(socketstate.dataBuffer, 0, socketstate.dataBuffer.Length, SocketFlags.None,
                    new AsyncCallback(ReceiveCallBack), socketstate);

            } catch (SocketException e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                MainSocket.BeginAccept(new AsyncCallback(onClientConnect), null);
            }
        }
Beispiel #2
0
 public void run()
 {
     SocketState st = new SocketState();
     Ph_Socket.BeginReceive(st.dataBuffer, 0, st.dataBuffer.Length,
         SocketFlags.None, new AsyncCallback(ReceiveCallBack), st);
 }
Beispiel #3
0
 public void run()
 {
     SocketState st = new SocketState();
     st.m_currentSocket = Lt_socket;
     Console.WriteLine("run linkit job");
     conn.ConnectionString = "integrated security=SSPI;data source=testDB;" +
                     "persist security info=False;initial catalog=mapping";
     Lt_socket.BeginReceive(st.dataBuffer, 0, st.dataBuffer.Length, SocketFlags.None,
                         new AsyncCallback(ReceiveCallBack), st);
 }