示例#1
0
        /// Client Received data from Server
        /// </summary>
        /// <param name="asyn">IAsyncResult</param>
        public void ClientDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket        socPacket = (SocketPacket)asyn.AsyncState;
                int                 iRx       = socPacket.mSocket.EndReceive(asyn);
                char[]              chars     = new char[iRx + 1];
                System.Text.Decoder d         = System.Text.Encoding.ASCII.GetDecoder();
                int                 charLen   = d.GetChars(socPacket.mDataBuffer, 0, iRx, chars, 0);
                string              data      = new System.String(chars);
                data = data.Trim();
                //Logger.TranferDataLog(" Reciep -" + data + "-" + DateTime.Now.ToString());
                if (data.Contains("RECEIVE"))
                {
                    TransferSaleDataToServer.GetScriptAndFlusToDataBase();
                }
                else
                if (data.Contains("TRANSFER"))     // format : TRANSFER -- ra lenh chuyen so lieu
                {
                    TransferSaleDataToServer.SaveFileAndLog();
                }

                ClientWaitData();
            }
            catch (SocketException ex)
            {
                Logger.TranferDataLog("SocketException " + ex.ToString());
                ClearConectSocket();
            }
            catch (Exception ex)
            {
                isCallRecieptData = true;
                Logger.TranferDataLog("Error Data ClientDataReceived: " + ex.ToString());
            }
        }
示例#2
0
 /// <summary>
 /// Chờ để hứng data
 /// </summary>
 /// <param name="socket"></param>
 public void ClientWaitData()
 {
     try
     {
         isCallRecieptData = false;
         if (ClientSocket == null)
         {
             return;
         }
         if (tfClientCallBack == null)
         {
             tfClientCallBack = new AsyncCallback(ClientDataReceived);
         }
         SocketPacket socPacket = new SocketPacket();
         socPacket.mSocket = ClientSocket;
         ClientSocket.BeginReceive(socPacket.mDataBuffer, 0, socPacket.mDataBuffer.Length, SocketFlags.None, tfClientCallBack, socPacket);
     }
     catch (SocketException ex)
     {
         ClearConectSocket();
     }
     catch (Exception ex)
     {
         isCallRecieptData = true;
         Logger.TranferDataLog(" Client is Wait Data with Error: " + ex.ToString());
     }
 }
示例#3
0
        private void OnDataReceivedC(IAsyncResult asyn)
        {
            try
            {
                SocketPacket theSockId = (SocketPacket)asyn.AsyncState;

                int    iRx            = theSockId.m_currentSocket.EndReceive(asyn);
                char[] chars          = new char[iRx + 1];
                System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
                int           charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
                System.String szData  = new System.String(chars);

                if (chars[0] == 13)
                {
                    //SetText(strRXServer);
                    this.OnDataReceivedFinish(this, new EventArgs());
                }
                else
                {
                    strRXServer += szData.Remove(1, 1);
                }
                //  textBox1.AppendText(szData);
                WaitForDataC();
            }
            catch (ObjectDisposedException)
            {
                System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
            }
            catch (SocketException se)
            {
                //MessageBox.Show(se.Message);
            }
        }
示例#4
0
        public void OnDataReceived(IAsyncResult asyn)
        {
            SocketPacket socketData = (SocketPacket)asyn.AsyncState;

            try {
                int    rx    = socketData.currentSocket.EndReceive(asyn);
                char[] chars = new char[rx + 1];

                System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
                int charLen           = d.GetChars(
                    socketData.dataBuffer,
                    0,
                    rx,
                    chars,
                    0
                    );

                string data = new String(chars);

                if (OnData != null)
                {
                    OnData(this, new DataEventArgs(data, socketData));
                }

                WaitForData();
            } catch (ObjectDisposedException) {
                // System.Diagnostics.Debugger.Log(0,"1","\nOnDataReceived: Socket has been closed\n");
            } catch (SocketException se) {
                // MessageBox.Show (se.Message );
            }
        }
示例#5
0
 // Start waiting for data from the client
 public static void WaitForData(System.Net.Sockets.Socket soc)
 {
     try
     {
         if (pfnWorkerCallBack == null)
         {
             // Specify the call back function which is to be
             // invoked when there is any write activity by the
             // connected client
             pfnWorkerCallBack = new AsyncCallback(OnDataReceived);
         }
         SocketPacket theSocPkt = new SocketPacket();
         theSocPkt.m_currentSocket = soc;
         // Start receiving any data written by the connected client
         // asynchronously
         soc.BeginReceive(theSocPkt.dataBuffer, 0,
                          theSocPkt.dataBuffer.Length,
                          SocketFlags.None,
                          pfnWorkerCallBack,
                          theSocPkt);
     }
     catch (SocketException se)
     {
         Globals.l2net_home.Add_Text("Errror: Wait for data, exception: " + se.Message, Globals.Red, TextType.BOT);
     }
 }
示例#6
0
        private string ArrayToStringNonInt(SocketPacket p, int startPos, int endPos)
        {
            string result = null;

            try
            {
                int         byteCount = endPos - startPos + 1;
                List <byte> byteArr   = new List <byte>();
                for (int i = startPos; i <= endPos; i++)
                {
                    byteArr.Add(p.dataBuffer[i]);
                }
                result = BitConverter.ToString(byteArr.ToArray());
                if (byteCount > 1)
                {
                    for (int i = 1; i < byteCount; i++)
                    {
                        result = result.Remove(i * 2, 1);
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#7
0
        public void OnDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket        theSockId = (SocketPacket)asyn.AsyncState;
                int                 iRx       = theSockId.thisSocket.EndReceive(asyn);
                char[]              chars     = new char[iRx + 1];
                System.Text.Decoder d         = System.Text.Encoding.UTF8.GetDecoder();
                int                 charLen   = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
                System.String       szData    = theSockId.string_RemoteEndPoint + ":" + (new System.String(chars));
                textBox_MSG.Invoke(new UpdateText(updateText), szData);
                WaitForData();
            }

            catch (ObjectDisposedException)
            {
                System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
            }
            catch (System.Exception se)
            {
                //MessageBox.Show("服务器断开连接,请检查服务器然后重新连接!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                this.textBox_MSG.AppendText(se.Message + "\r\n");
                button2.PerformClick();
            }
        }
    public void sendClientPacket(SocketPacket packet)
    {
        if (mServerSocket == null || !mServerSocket.Connected || mConnectState != CONNECT_STATE.CS_CONNECTED)
        {
            mSocketFactory.destroyPacket(packet);
            return;
        }
        // 将消息包中的数据准备好,然后放入发送列表中
        // 前四个字节分别是两个short,代表消息类型和消息内容长度
        PACKET_TYPE type       = packet.getPacketType();
        ushort      packetSize = (ushort)packet.generateSize();

        byte[] packetData = getUnusedBytes(CommonDefine.PACKET_HEADER_SIZE + packetSize);
        memset(packetData, (byte)0);
        int index = 0;

        writeInt(packetData, ref index, (int)type);
        writeUShort(packetData, ref index, packetSize);
        if (packetSize > 0 && !packet.write(packetData, CommonDefine.PACKET_HEADER_SIZE))
        {
            mSocketFactory.destroyPacket(packet);
            mCollectedBytes.addToBuffer(packetData);
            logError("消息序列化失败!");
            return;
        }
        logInfo("已发送 : " + type + ", 字节数:" + packetSize, LOG_LEVEL.LL_LOW);
        // 添加到写缓冲中
        mOutputBuffer.addToBuffer(packetData);
    }
示例#9
0
        private void CallBack_OnDataReceived(IAsyncResult AR)
        {
            SocketPacket socketData = (SocketPacket)AR.AsyncState;

            try
            {
                int    iRxData = socketData.CurrentClient.GetStream().EndRead(AR);
                char[] chars   = new char[iRxData + 1];
                int    charLen = 0;

                Decoder decoder = Encoding.ASCII.GetDecoder();
                charLen = decoder.GetChars(socketData.DataBuffer,
                                           0, iRxData, chars, 0);

                String msg = new String(chars);

                OnReceivedMsgFromClient(msg, socketData.ClientNo);

                WaitForData(socketData.CurrentClient, socketData.ClientNo);
            }
            catch (ObjectDisposedException ex)
            {
            }
            catch (SocketException ex)
            {
                if (ex.ErrorCode == 10054)
                {
                    OnClientDisconnected(ex.Message, socketData.ClientNo);

                    m_tcpWorkerList[socketData.ClientNo - 1] = null;
                }
            }
        }
示例#10
0
        public void OnDataReceived(IAsyncResult asyn)
        {
            int ClientID = tempint;

            try
            {
                SocketPacket socketData = (SocketPacket)asyn.AsyncState;
                LenghtOfDataRecieved = socketData.RealmserverSocket.EndReceive(asyn);
                char[] chars = new char[LenghtOfDataRecieved + 1];
                System.Text.Decoder decode = System.Text.Encoding.UTF8.GetDecoder();
                int charLen = decode.GetChars(socketData.dataBuffer,
                                              0, LenghtOfDataRecieved, chars, 0);
                System.String szData = new System.String(chars);
                if (LenghtOfDataRecieved != 0)
                {
                    ProcessRecieved(socketData.dataBuffer, ClientID);
                }
                Thread.Sleep(50);
                WaitForData(socketData.RealmserverSocket, ClientID);
            }
            catch (ObjectDisposedException)
            {
                System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
            }
            catch (SocketException se)
            {
                ColoredConsole.ConsoleWriteErrorWithOut(se.Message);
            }
        }
示例#11
0
        /**************************************************************************************************************
         * 函数实现
         *************************************************************************************************************/

        // 构造函数
        public SocketClient()
        {
            // 初始化
            serverIP           = "";
            serverPort         = -1;
            connected          = false;
            endDelimiter       = "";
            receivedData       = "";
            receivedBytes      = new byte[1024];
            receivedBytesIndex = 0;

            socket     = null;
            dataPacket = new SocketPacket();

            OnError        = null;
            OnConnected    = null;
            OnDisconnected = null;
            OnData         = null;
            OnDataBytes    = null;

            // 创建SOCKET连接状态检查定时器
            checkSocketTimer           = new System.Timers.Timer(1000);
            checkSocketTimer.Elapsed  += new System.Timers.ElapsedEventHandler(CheckSocketStatus);
            checkSocketTimer.AutoReset = true;
            checkSocketTimer.Enabled   = true;
        }  // TcpClient()
示例#12
0
        public void OnDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket socketData = (SocketPacket)asyn.AsyncState;

                int bytesReceived = 0;
                bytesReceived = socketData.m_currentSocket.EndReceive(asyn);
                byte[] buffer = new byte[bytesReceived + 1];

                buffer = socketData.dataBuffer;

                IFormatter formatter = new BinaryFormatter();
                Stream     stream    = new MemoryStream();

                stream.Write(buffer, 0, buffer.Length);
                stream.Seek(0, 0);

                tet_network_object objReceived = (tet_network_object)formatter.Deserialize(stream);

                parseObject(objReceived);

                stream.Close();

                WaitForData(socketData.m_currentSocket);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something bad happened : " + ex.Message, "Battle Tetrix", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                Application.Restart();
            }
        }
        void HandleMessage(SocketPacket packet)
        {
            if (packet.json == "")
            {
                return;
            }

            if (packet.socketPacketType == SocketPacketType.ACK)
            {
                for (int i = 0; i < ackList.Count; i++)
                {
                    if (ackList[i].packetID != packet.id)
                    {
                        continue;
                    }

                    lock (ackQueueLock) {
                        ackQueue.Enqueue(packet);
                    }

                    return;
                }
            }

            if (packet.socketPacketType == SocketPacketType.EVENT)
            {
                SocketIOEvent e = parser.Parse(packet.json);

                lock (eventQueueLock) {
                    eventQueue.Enqueue(e);
                }
            }
        }
示例#14
0
        public static void OnDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket theSockId = (SocketPacket)asyn.AsyncState;
                int          iRx       = theSockId.thisSocket.EndReceive(asyn);
                byte[]       message   = new byte[iRx];

                Buffer.BlockCopy(theSockId.dataBuffer, 0, message, 0, iRx);
                string gg = "";

                for (int i = 0; i < message.Length; i++)
                {
                    gg += message[i].ToString("X2") + " ";
                }
                Globals.l2net_home.Add_Text("Data: " + gg, Globals.Yellow, TextType.BOT);
                Globals.l2net_home.Add_Text("Lenght: " + iRx.ToString(), Globals.Yellow, TextType.BOT);
                Globals.l2net_home.Add_Text("Received gameguard reply from GG server", Globals.Green, TextType.BOT);

                ByteBuffer bout = new ByteBuffer(message);
                Globals.gamedata.SendToGameServer(bout);

                WaitForData();
            }
            catch (SocketException se)
            {
                Globals.l2net_home.Add_Text("OnDataReceived, exception: " + se.Message, Globals.Red, TextType.BOT);
            }
        }
示例#15
0
        private string ArrayToString(SocketPacket p, int startPos, int endPos)
        {
            string result = null;

            try
            {
                int         byteCount = endPos - startPos + 1;
                List <byte> byteArr   = new List <byte>();
                for (int i = startPos; i <= endPos; i++)
                {
                    byteArr.Add(p.dataBuffer[i]);
                }
                result = BitConverter.ToString(byteArr.ToArray());
                if (byteCount > 1)
                {
                    for (int i = 1; i < byteCount; i++)
                    {
                        result = result.Remove(i * 2, 1);
                    }
                }
                result = int.Parse(result, System.Globalization.NumberStyles.HexNumber).ToString();
                return(result);
            }
            catch (Exception ex)
            {
                return(null);

                Console.WriteLine(ex.ToString());
            }
        }
        public void WaitForData(Socket soc, int clientNumber)
        {
            SocketPacket theSocPkt = new SocketPacket(soc, clientNumber);

            try
            {
                if (pfnWorkerCallBack == null)
                {
                    pfnWorkerCallBack = new AsyncCallback(OnDataReceived);
                }
                soc.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length, SocketFlags.None, pfnWorkerCallBack, theSocPkt);
            }
            catch (SocketException se)
            {
                if (se.ErrorCode == 10053)
                {
                    string msg = theSocPkt.string_RemoteEndPoint.ToString() + " Disconnected";
                    AppendToRichEditControl(msg);
                    m_workerSocketList[theSocPkt.m_clientNumber - 1] = null;
                    UpdateClientListControl();
                }
                else
                {
                    MessageBox.Show(se.Message);
                }
            }
        }
示例#17
0
    public void sendServerPacket(SocketPacket packet)
    {
        // 将消息包中的数据准备好,然后放入发送列表中
        // 前四个字节分别是两个short,代表消息类型和消息内容长度
        ushort packetSize = (ushort)packet.generateSize();

        byte[] packetData = new byte[CommonDefine.PACKET_HEADER_SIZE + packetSize];
        int    index      = 0;

        // 消息类型
        writeInt(packetData, ref index, (int)packet.getPacketType());
        // 消息长度
        writeInt(packetData, ref index, packetSize);
        // 消息内容
        if (packetSize > 0 && !packet.write(packetData, CommonDefine.PACKET_HEADER_SIZE))
        {
            clientError("消息序列化失败 : " + packet.getPacketType());
            return;
        }
        // 添加到写缓冲中
        mOutputBuffer.addToBuffer(packetData);
        if (packet.showInfo())
        {
            clientInfo("已发送 : " + packet.debugInfo() + ", 字节数:" + packetSize);
        }
    }
 public void WaitForData()
 {
     try
     {
         if (_pfnCallBack == null)
         {
             _pfnCallBack = new AsyncCallback(OnDataReceived);
         }
         SocketPacket theSocPkt = new SocketPacket();
         theSocPkt.thisSocket = _clientSocket;
         // Start listening to the data asynchronously
         _result = _clientSocket.BeginReceive(theSocPkt.dataBuffer,
                                              0, theSocPkt.dataBuffer.Length,
                                              SocketFlags.None,
                                              _pfnCallBack,
                                              theSocPkt);
     }
     catch (SocketException se)
     {
         MessageBox.Show(se.Message);
     }
     catch (NullReferenceException ne)
     {
         MessageBox.Show(ne.Message);
     }
 }
示例#19
0
        public void WaitForData()
        {
            try
            {
                if (m_clientSocket == null)
                {
                    return;
                }

                if (m_pfnCallBack == null)
                {
                    m_pfnCallBack = new AsyncCallback(OnDataReceived);
                }
                SocketPacket theSocPkt = new SocketPacket();
                theSocPkt.dataBuffer = new byte[BUFFER_SIZE];
                // Start listening to the data asynchronously
                m_result = m_clientSocket.BeginReceive(theSocPkt.dataBuffer,
                                                       0, theSocPkt.dataBuffer.Length,
                                                       SocketFlags.None,
                                                       m_pfnCallBack,
                                                       theSocPkt);
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
 // Start waiting for data from the client
 public void WaitForData(System.Net.Sockets.Socket soc)
 {
     try
     {
         if (pfnWorkerCallBack == null)
         {
             // Specify the call back function which is to be
             // invoked when there is any write activity by the
             // connected client
             pfnWorkerCallBack = new AsyncCallback(OnDataReceived);
         }
         SocketPacket theSocPkt = new SocketPacket();
         theSocPkt.m_currentSocket = soc;
         // Start receiving any data written by the connected client
         // asynchronously
         soc.BeginReceive(theSocPkt.dataBuffer, 0,
                          theSocPkt.dataBuffer.Length,
                          SocketFlags.None,
                          pfnWorkerCallBack,
                          theSocPkt);
     }
     catch (SocketException se)
     {
         MessageBox.Show(se.Message);
     }
 }
示例#21
0
        // This the call back function which will be invoked when the socket
        // detects any client writing of data on the stream
        public void OnDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket socketData = (SocketPacket)asyn.AsyncState;

                int iRx = 0;
                // Complete the BeginReceive() asynchronous call by EndReceive() method
                // which will return the number of characters written to the stream
                // by the client
                iRx = socketData.m_currentSocket.EndReceive(asyn);
                CDataObject obj = new CDataObject();
                obj.Copy(socketData.dataBuffer, iRx, socketData.m_currentSocket);
                AddReceiveData(obj);
                WaitForData(socketData.m_currentSocket);
            }
            catch (ObjectDisposedException)
            {
                //System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
                Debug.WriteLine("\nOnDataReceived: Socket has been closed\n");
            }
            catch (SocketException se)
            {
            }
        }
        // This the call back function which will be invoked when the socket
        // detects any client writing of data on the stream
        public void OnDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket socketData = (SocketPacket)asyn.AsyncState;

                int iRx = 0;
                // Complete the BeginReceive() asynchronous call by EndReceive() method
                // which will return the number of characters written to the stream
                // by the client
                iRx = socketData.m_currentSocket.EndReceive(asyn);
                char[] chars          = new char[iRx + 1];
                System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
                int charLen           = d.GetChars(socketData.dataBuffer,
                                                   0, iRx, chars, 0);
                System.String szData = new System.String(chars);
                richTextBoxReceivedMsg.AppendText(szData);

                // Continue the waiting for data on the Socket
                WaitForData(socketData.m_currentSocket);
            }
            catch (ObjectDisposedException)
            {
                System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
示例#23
0
    //------------------------------------------------------------------------------------------------------------
    protected SocketPacket createPacket(Type classType, PACKET_TYPE packetType)
    {
        SocketPacket packet = UnityUtility.createInstance <SocketPacket>(classType, packetType);

        packet.init();
        return(packet);
    }
示例#24
0
 public void WaitForData()
 {
     if (networkSocket != null)
     {
         try
         {
             if (m_pfnCallBack == null)
             {
                 PrintDebug(3, "Creating m_pfnCallBack");
                 m_pfnCallBack = new AsyncCallback(OnDataReceived);
             }
             PrintDebug(3, "WaitForData");
             SocketPacket theSocPkt = new SocketPacket();
             theSocPkt.thisSocket = networkSocket;
             // Start listening to the data asynchronously
             m_result = networkSocket.BeginReceive(theSocPkt.dataBuffer,
                                                   0, theSocPkt.dataBuffer.Length,
                                                   SocketFlags.None,
                                                   m_pfnCallBack,
                                                   theSocPkt);
         }
         catch (SocketException se)
         {
             MessageBox.Show("WaitForData exception:" + se.Message + "Error codes:" + se.ErrorCode);
         }
         catch (Exception ex)
         {
             PrintDebug(1, "WaitForData exception:" + ex);
         }
     }
 }
示例#25
0
 public void OnDataReceived(IAsyncResult asyn)
 {
     try
     {
         PrintDebug(3, "OnDataReceived");
         SocketPacket        theSockId = (SocketPacket)asyn.AsyncState;
         int                 iRx       = theSockId.thisSocket.EndReceive(asyn);
         char[]              chars     = new char[iRx];
         System.Text.Decoder d         = System.Text.Encoding.UTF8.GetDecoder();
         int                 charLen   = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
         System.String       szData    = new System.String(chars);
         //printDebug("", szData);
         ProcessData(szData);
         if (networkSocket != null && networkSocket.Connected)
         {
             WaitForData();
         }
     }
     catch (ObjectDisposedException)
     {
         System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
     }
     catch (SocketException se)
     {
         MessageBox.Show("onDataReceived exception:" + se.Message);
     }
 }
示例#26
0
        public void OnDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket        theSockId = (SocketPacket)asyn.AsyncState;
                int                 iRx       = theSockId.thisSocket.EndReceive(asyn);
                char[]              chars     = new char[iRx + 1];
                System.Text.Decoder d         = System.Text.Encoding.UTF8.GetDecoder();
                int                 charLen   = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
                System.String       szData    = new System.String(chars);

                SetRichText(szData);

                //richTextRxMessage.Text = richTextRxMessage.Text + szData;
                WaitForData();
            }
            catch (ObjectDisposedException)
            {
                System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
示例#27
0
 void OnDataReceived(IAsyncResult asyn)
 {
     try
     {
         SocketPacket        packet = (SocketPacket)asyn.AsyncState;
         int                 end    = packet.TCPSocket.EndReceive(asyn);
         char[]              chars  = new char[end + 1];
         System.Text.Decoder d      = System.Text.Encoding.UTF8.GetDecoder();
         d.GetChars(packet.DataBuffer, 0, end, chars, 0);
         System.String data = new System.String(chars);
         ReceiveData(data);
         WaitForData();
     }
     catch (ObjectDisposedException)
     {
         Console.WriteLine("WARNING: Socket closed unexpectedly");
     }
     catch (SocketException se)
     {
         if (!_TCPSocket.Connected)
         {
             if (OnDisconnected != null)
             {
                 OnDisconnected(se);
             }
         }
     }
 }
示例#28
0
        private void OnDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket socketData = (SocketPacket)asyn.AsyncState;

                int bytesReceived = 0;
                bytesReceived = socketData.thisSocket.EndReceive(asyn);
                byte[] buffer = new byte[bytesReceived + 1];

                buffer = socketData.dataBuffer;

                IFormatter formatter = new BinaryFormatter();
                Stream     stream    = new MemoryStream();

                stream.Write(buffer, 0, buffer.Length);
                stream.Seek(0, 0);

                dataTypes objReceived = new dataTypes();

                objReceived = (dataTypes)formatter.Deserialize(stream);

                parseObject(objReceived);

                WaitForData();
            }
            catch (ObjectDisposedException)
            {
                System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
示例#29
0
        // Start waiting for data from the client
        private void WaitForData(System.Net.Sockets.Socket soc)
        {
            try
            {
                if (workerCallback == null)
                {
                    //Callback for data received from the client
                    workerCallback = new AsyncCallback(OnDataReceived);
                }

                SocketPacket theSocPkt = new SocketPacket();
                theSocPkt.currentSocket = soc;
                // Start receiving any data written by the connected client
                // asynchronously
                soc.BeginReceive(theSocPkt.dataBuffer, 0,
                                 theSocPkt.dataBuffer.Length,
                                 SocketFlags.None,
                                 workerCallback,
                                 theSocPkt);
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
        void OnSocketMessage(object sender, MessageEventArgs e)
        {
            SocketPacket packet = decoder.Decode(e);

            switch (packet.enginePacketType)
            {
            case EnginePacketType.OPEN:
                HandleOpen(packet);
                break;

            case EnginePacketType.CLOSE:
                EmitEvent("close");
                break;

            case EnginePacketType.MESSAGE:
                HandleMessage(packet);
                break;

            case EnginePacketType.PING:
                HandlePing();
                break;

            case EnginePacketType.PONG:
                HandlePong();
                break;
            }
        }
        public static string GetPacketAsString(SocketPacket socketPacket)
        {
            int iRx = socketPacket.DataBuffer.GetLength(0);

            char[] chars = new char[iRx + 1];

            // Extract the characters as a buffer
            System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
            int charLen = d.GetChars(socketPacket.DataBuffer, 0, iRx, chars, 0);

            var szData = new String(chars);
            return szData;
        }
示例#32
0
 void WaitForData()
 {
     try
     {
         if (DataCallback == null) DataCallback = new AsyncCallback(OnDataReceived);
         SocketPacket theSocPkt = new SocketPacket();
         theSocPkt.thisSocket = sockIRC;
         AsyncResult = sockIRC.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length, SocketFlags.None, DataCallback, theSocPkt);
     }
     catch (SocketException se)
     {
         Console.WriteLine(se.Message);
     }
 }
示例#33
0
 /// <summary>
 /// An always-active function that waits for the client to send data to the server. Eventually trigers OnDataReceived().
 /// </summary>
 /// <param name="waitClientInfo">Associated ClientInfo object</param>
 private static void WaitForData(ClientInfo waitClientInfo)
 {
     if (asyncWorkerCallBack == null) { asyncWorkerCallBack = new AsyncCallback(OnDataReceived); }
     SocketPacket tempSocketPacket = new SocketPacket(waitClientInfo);
     waitClientInfo.Socket.BeginReceive(
         tempSocketPacket.DataBuffer,
         0,
         tempSocketPacket.DataBuffer.Length,
         SocketFlags.None,
         asyncWorkerCallBack,
         tempSocketPacket
     );
 }
示例#34
0
 public void WaitForData2()
 {
     try
     {
         if (m_pfnCallBack2 == null)
         {
             m_pfnCallBack2 = new AsyncCallback(OnDataReceived2);
         }
         SocketPacket theSocPkt = new SocketPacket();
         theSocPkt.thisSocket = m_clientSocket;
         // Start listening to the data asynchronously
         m_result = m_clientSocket.BeginReceive(theSocPkt.dataBuffer,
                                                 0, theSocPkt.dataBuffer.Length,
                                                 SocketFlags.None,
                                                 m_pfnCallBack2,
                                                 theSocPkt);
     }
     catch (SocketException se)
     {
         MessageBox.Show("ERROR" + se.Message);
         this.Close();
     }
 }
示例#35
0
 /// <summary>
 /// waits for data to come back from the stereo feature service
 /// </summary>
 private void WaitForData()
 {
     try
     {
         if (m_pfnCallBack == null)
         {
             m_pfnCallBack = new AsyncCallback(OnDataReceived);
         }
         SocketPacket theSocPkt = new SocketPacket();
         theSocPkt.thisSocket = m_clientSocket;
         // Start listening to the data asynchronously
         m_clientSocket.BeginReceive(theSocPkt.dataBuffer,
                                      0, theSocPkt.dataBuffer.Length,
                                      SocketFlags.None,
                                      m_pfnCallBack,
                                      theSocPkt);
     }
     catch (SocketException se)
     {
         Console.WriteLine("Error whilst waiting for stereo feature service replies: " + se.Message);
     }
 }
示例#36
0
 /// <summary>
 /// An always-active function that waits for the server to send data to the client. Eventually trigers OnDataReceived().
 /// </summary>
 /// <param name="waitServerInfo">Associated Server object</param>
 private static void WaitForData(Socket ServerSock)
 {
     if (asyncCallBack == null) { asyncCallBack = new AsyncCallback(OnDataReceived); }
     SocketPacket SocketPacket = new SocketPacket(ServerSock);
     asyncResult = SocketPacket.Socket.BeginReceive(
         SocketPacket.DataBuffer,
         0, SocketPacket.DataBuffer.Length,
         SocketFlags.None,
         asyncCallBack,
         SocketPacket
     );
 }
示例#37
0
        private void WaitForData()
        {
            try
            {
                if  (_pfnCallBack == null )
                    _pfnCallBack = new AsyncCallback (OnDataReceived);

                SocketPacket theSocPkt = new SocketPacket (_socket);

                // Start listening to the m_data asynchronously
                _asyncResult = _socket.BeginReceiveFrom (theSocPkt.Buffer,
                    0, theSocPkt.BufferSize,
                    SocketFlags.None,
                    ref _remoteEndPoint,
                    _pfnCallBack, theSocPkt);
            }
            catch(SocketException exc)
            {
                Debug.WriteLine ("Error waiting for m_data: " + exc.ToString ());
            }
        }
示例#38
0
文件: Form1.cs 项目: golfpunx/CIT
 private void WaitForDataC()
 {
     try
     {
         if (m_pfnCallBack == null)
         {
             m_pfnCallBack = new AsyncCallback(OnDataReceivedC);
         }
         SocketPacket theSocPkt = new SocketPacket();
         theSocPkt.m_currentSocket = m_clientSocket;
         // Start listening to the data asynchronously
         m_result = m_clientSocket.BeginReceive(theSocPkt.dataBuffer,
                                                 0, theSocPkt.dataBuffer.Length,
                                                 SocketFlags.None,
                                                 m_pfnCallBack,
                                                 theSocPkt);
     }
     catch (SocketException se)
     {
         //MessageBox.Show(se.Message);
     }
 }
示例#39
0
 public void WaitForData(Socket m_socWorker)
 {
     try
     {
         if (pfnWorkerCallback == null)
         {
             pfnWorkerCallback = new AsyncCallback(OnDataReceived);
         }
         SocketPacket theSokPkt = new SocketPacket();
         theSokPkt.m_currentSocket = m_socWorker;
         m_socWorker.BeginReceive(theSokPkt.dataBuffer, 0,
             theSokPkt.dataBuffer.Length,
             SocketFlags.None,
             pfnWorkerCallback,
             theSokPkt);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Something bad happened : " + ex.Message, "Battle Tetrix", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         Application.Restart();
     }
 }
示例#40
0
        public void WaitForData(System.Net.Sockets.Socket oSocket)
        {
            try
            {
                if (oWorkerCallBack == null)
                    oWorkerCallBack = new AsyncCallback(OnReceive);

                SocketPacket oSocketPacket = new SocketPacket();
                oSocketPacket.oSocket = oSocket;

                // Start Listening for any Data
                oSocket.BeginReceive(oSocketPacket.bDataBuffer, 0,
                    oSocketPacket.bDataBuffer.Length, SocketFlags.None, oWorkerCallBack,
                    oSocketPacket);
            }
            catch (SocketException ex)
            {
                System.Diagnostics.Debugger.Log(0, "1", ex.Message);
            }
        }
示例#41
0
        public static void WaitForData()
        {
            try
            {
                if (m_pfnCallBack == null)
                {
                    m_pfnCallBack = new AsyncCallback(OnDataReceived);
                }
                SocketPacket theSocPkt = new SocketPacket();
                theSocPkt.thisSocket = m_clientSocket;
                // Start listening to the data asynchronously
                m_result = m_clientSocket.BeginReceive(theSocPkt.dataBuffer,
                                                        0, theSocPkt.dataBuffer.Length,
                                                        SocketFlags.None,
                                                        m_pfnCallBack,
                                                        theSocPkt);
            }
            catch (SocketException se)
            {
                Globals.l2net_home.Add_Text("WaitForData, exception: " + se.Message, Globals.Red, TextType.BOT);
            }

        }
示例#42
0
        public void WaitForData()
        {
            try
            {
                if  ( m_pfnCallBack == null )
                {
                    m_pfnCallBack = new AsyncCallback (OnDataReceived);
                }
                if (this.pClientSocket == null) return;

                if (!this.pClientSocket.Connected)
                {
                    this.Disconnect();
                }

                if (this.pClientSocket == null) return;
                SocketPacket theSocPkt = new SocketPacket ();
                theSocPkt.thisSocket = this.pClientSocket;
                // Start listening to the data asynchronously
                m_result = this.pClientSocket.BeginReceive (theSocPkt.dataBuffer,
                    0, theSocPkt.dataBuffer.Length,
                    SocketFlags.None,
                    m_pfnCallBack,
                    theSocPkt);
            }
            catch(SocketException se)
            {
                System.Diagnostics.Debugger.Log(0,"1","\nWaitForData: " + se.Message );
                this.Disconnect();

            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
示例#43
0
        // Start waiting for data from the client
        public static void WaitForData(System.Net.Sockets.Socket soc)
        {
            try
            {
                if (pfnWorkerCallBack == null)
                {
                    // Specify the call back function which is to be 
                    // invoked when there is any write activity by the 
                    // connected client
                    pfnWorkerCallBack = new AsyncCallback(OnDataReceived);
                }
                SocketPacket theSocPkt = new SocketPacket();
                theSocPkt.m_currentSocket = soc;
                // Start receiving any data written by the connected client
                // asynchronously
                soc.BeginReceive(theSocPkt.dataBuffer, 0,
                                   theSocPkt.dataBuffer.Length,
                                   SocketFlags.None,
                                   pfnWorkerCallBack,
                                   theSocPkt);
            }
            catch (SocketException se)
            {
                Globals.l2net_home.Add_Text("Errror: Wait for data, exception: " + se.Message, Globals.Red, TextType.BOT);
            }

        }
        // Start waiting for data from the client
        private void WaitForData(Socket soc, int clientNumber)
        {
            try
            {
                if (_workerCallBack == null)
                {
                    // Specify the call back function which is to be
                    // invoked when there is any write activity by the
                    // connected client
                    _workerCallBack = new AsyncCallback(OnDataReceived);
                }
                SocketPacket theSocPkt = new SocketPacket(soc, clientNumber);

                soc.BeginReceive(theSocPkt.DataBuffer, 0,
                    theSocPkt.DataBuffer.Length,
                    SocketFlags.None,
                    _workerCallBack,
                    theSocPkt);
            }
            catch (SocketException e)
            {
                HandleException("Wait for data", e);
            }
        }
示例#45
0
文件: Form1.cs 项目: golfpunx/CIT
 private void WaitForDataS(Socket soc)
 {
     try
     {
         if (pfnWorkerCallBack == null)
         {
             pfnWorkerCallBack = new AsyncCallback(OnDataReceivedS);
         }
         SocketPacket theSocPkt = new SocketPacket();
         theSocPkt.m_currentSocket = soc;
         // Start receiving any data written by the connected client
         // asynchronously
         soc.BeginReceive(theSocPkt.dataBuffer, 0,
                            theSocPkt.dataBuffer.Length,
                            SocketFlags.None,
                            pfnWorkerCallBack,
                            theSocPkt);
     }
     catch (SocketException se)
     {
         //MessageBox.Show(se.Message);
     }
 }
示例#46
0
        public void processCommand(String command, SocketPacket socketData)
        {
            string[] commandSplit = command.Remove(command.Length - 1).Split(',');
            try
            {
                Socket workerSocket = (Socket)socketData.m_currentSocket;
                string name = commandSplit[1];

                switch (commandSplit[0])
                {
                    case "Create":
                        accountManager.CreateAccount(name);
                        byte[] byData = System.Text.Encoding.ASCII.GetBytes("Session ID: " + socketData.m_clientNumber + " Server Reply: " + name + " has been created.\n");
                        workerSocket.Send(byData);
                        break;
                    case "Balance":
                        byData = System.Text.Encoding.ASCII.GetBytes("Session ID: " + socketData.m_clientNumber + " Server Reply: " + accountManager.GetBalance(name)+"\n");
                        workerSocket.Send(byData);
                        break;
                    case "Deposit":
                        decimal depositAmt;
                        Decimal.TryParse(commandSplit[2].Trim(), out depositAmt);
                        accountManager.DepositAmount(name, depositAmt);
                        break;
                    case "Withdraw":
                        decimal withdrawAmt;
                        Decimal.TryParse(commandSplit[2].Trim(), out withdrawAmt);
                        accountManager.WithdrawAmount(name, withdrawAmt);
                        break;
                    default:
                        Console.WriteLine(command + ": Is not a Command\n");
                        break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 /// <summary>
 /// Waits for data.
 /// 
 /// This Method Waits for Data to be recieved by telnet, Once it is recieved, it will
 /// then Begin to recieve this message, This is done by the SocketPacket Class
 /// </summary>
 /// <param name="soc">Soc.</param>
 /// <param name="clientNumber">Client number.</param>
 public void WaitForData(System.Net.Sockets.Socket soc, int clientNumber)
 {
     try
     {
         if (pfnWorkerCallBack == null)
         {
             pfnWorkerCallBack = new AsyncCallback(OnDataReceived);
         }
         SocketPacket theSocPkt = new SocketPacket(soc, clientNumber);
         soc.BeginReceive(theSocPkt.dataBuffer, 0,theSocPkt.dataBuffer.Length,SocketFlags.None,pfnWorkerCallBack,theSocPkt);
     }
     catch (SocketException se)
     {
         Console.WriteLine(se.Message);
     }
 }
示例#48
0
 void WaitForData()
 {
     try
     {
         if (_Callback == null) _Callback = new AsyncCallback(OnDataReceived);
         SocketPacket packet = new SocketPacket();
         packet.TCPSocket = _TCPSocket;
         _Result = _TCPSocket.BeginReceive(packet.DataBuffer, 0, packet.DataBuffer.Length, SocketFlags.None, _Callback, packet);
     }
     catch (SocketException se)
     {
         Console.WriteLine(se.Message);
     }
 }
示例#49
0
 public void WaitForData()
 {
     try
     {
         if (m_pfnCallBack == null)
         {
             m_pfnCallBack = new AsyncCallback(OnDataReceived);
         }
         SocketPacket theSocPkt = new SocketPacket();
         theSocPkt.thisSocket = m_clientSocket;
         // Start listening to the data asynchronously
         m_result = m_clientSocket.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length, SocketFlags.None, m_pfnCallBack, theSocPkt);
     }
     catch (SocketException se)
     {
         Console.WriteLine(se.Message);
     }
 }
        public void EsperarData(System.Net.Sockets.Socket soc)
        {
            try
            {
                if (pfnWorkerCallBack == null)
                {
                    // Specify the call back function which is to be
                    // invoked when there is any write activity by the
                    // connected client
                    pfnWorkerCallBack = new AsyncCallback(AlRecibirData);
                }
                SocketPacket theSocPkt = new SocketPacket();
                theSocPkt.m_currentSocket = soc;

                //Comienza a recibir la data escrita por el cliente, usando el metodo Asincrono
                soc.BeginReceive(theSocPkt.dataBuffer, 0,
                                   theSocPkt.dataBuffer.Length,
                                   SocketFlags.None,
                                   pfnWorkerCallBack,
                                   theSocPkt);
            }
            catch (SocketException)
            {
            }
        }
示例#51
0
 private void WaitForData(System.Net.Sockets.Socket soc)
 {
     try
     {
         if(WorkerCallBack == null)
             WorkerCallBack = new AsyncCallback(OnDataReceived);
         SocketPacket theSocPkt = new SocketPacket(soc);
         soc.BeginReceive(theSocPkt.dataBuffer, 0,
             theSocPkt.dataBuffer.Length,
             SocketFlags.None,
             WorkerCallBack,
             theSocPkt);
     }
     catch(SocketException se)
     {
         if(OnError != null)
             OnError(se.Message, soc, se.ErrorCode);
     }
 }
示例#52
0
        // Start waiting for data from the client
        public void WaitForData(System.Net.Sockets.Socket soc)
        {
            try
            {
                if  ( pfnWorkerCallBack == null ){
                    // Specify the call back function which is to be
                    // invoked when there is any write activity by the
                    // connected client
                    pfnWorkerCallBack = new AsyncCallback (OnDataReceived);
                }
                SocketPacket theSocPkt = new SocketPacket ();
                theSocPkt.m_currentSocket 	= soc;
                // Start receiving any data written by the connected client
                // asynchronously
                soc .BeginReceive (theSocPkt.dataBuffer, 0,
                                   theSocPkt.dataBuffer.Length,
                                   SocketFlags.None,
                                   pfnWorkerCallBack,
                                   theSocPkt);
            }
            catch(SocketException se)
            {
                MessageBox.Show (se.Message );

            }
        }
示例#53
0
        private bool waitForData() {
            try {
                if (m_clientSocket == null || !m_clientSocket.Connected)
                { return false; }

                if (m_pfnCallBack == null)
                { m_pfnCallBack = new AsyncCallback(onDataReceived); }

                if (_theSocPkt == null) {
                    _theSocPkt = new SocketPacket();
                    _theSocPkt.dataBuffer = new byte[BUFFER_SIZE];
                }

                if (m_clientSocket != null) {
                    // Start listening to the data asynchronously
                    m_clientSocket.BeginReceive(_theSocPkt.dataBuffer,
                                                0, _theSocPkt.dataBuffer.Length,
                                                SocketFlags.None,
                                                m_pfnCallBack,
                                                _theSocPkt);

                    return true;
                }

            } catch (SocketException se) {
                MessageBox.Show(se.Message, Resources.ConnectError);
            }

            return false;
        }
示例#54
0
 private void WaitForData()
 {
     try
     {
         if (m_pfnCallBack == null)
         {
             m_pfnCallBack = new AsyncCallback(OnDataReceived);
         }
         SocketPacket theSocPkt = new SocketPacket();
         theSocPkt.thisSocket = m_clientSocket;
         m_result = m_clientSocket.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length, SocketFlags.None, m_pfnCallBack, theSocPkt);
     }
     catch (SocketException se)
     {
         MessageBox.Show(se.Message);
     }
 }
示例#55
0
        private void WaitForData()
        {
            SocketPacket myData = new SocketPacket();
            myData.assocSocket = this._sck;

            try
            {
                this._sck.BeginReceive(myData.dataBuffer, 0, myData.dataBuffer.Length, SocketFlags.None, new AsyncCallback(onDataReceived), myData);
            }
            catch (SocketException se)
            {
                this.OnSocketError(new SocketErrorEventArgs(se.ErrorCode, se.Message));
            }
        }
        private void WaitForData()
        {
            try
            {
                if (m_pfnCallBack == null)
                {
                    m_pfnCallBack = new AsyncCallback(OnDataReceived);
                }
                SocketPacket theSocPkt = new SocketPacket();
                theSocPkt.thisSocket = Socket;

                // Start listening to the data asynchronously
                if (Socket != null)
                    m_result = Socket.BeginReceive(theSocPkt.dataBuffer,
                                                           0, theSocPkt.dataBuffer.Length,
                                                           SocketFlags.None,
                                                           m_pfnCallBack,
                                                           theSocPkt);
            }
            catch (SocketException se)
            {
                HandleException("Wait for data", se);
            }
        }
示例#57
0
        // Start waiting for data from the client
        public void WaitForData(System.Net.Sockets.Socket soc, int clientNumber)
        {
            try
            {
                if (pfnWorkerCallBack == null)
                {
                    // Specify the call back function which is to be
                    // invoked when there is any write activity by the
                    // connected client
                    pfnWorkerCallBack = new AsyncCallback(OnDataReceived);
                }
                SocketPacket theSocPkt = new SocketPacket(soc, clientNumber);

                soc.BeginReceive(theSocPkt.dataBuffer, 0,
                    theSocPkt.dataBuffer.Length,
                    SocketFlags.None,
                    pfnWorkerCallBack,
                    theSocPkt);
            }
            catch (SocketException se)
            {
                WriteLogErorr("Err WaitForData: " + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + ":" + se.Message);
            }
        }
        // Start waiting for data from the client
        private void WaitForData(System.Net.Sockets.Socket soc)
        {
            try
            {
                if (workerCallback == null)
                {
                    //Callback for data received from the client
                    workerCallback = new AsyncCallback(OnDataReceived);
                }

                SocketPacket theSocPkt = new SocketPacket();
                theSocPkt.currentSocket = soc;
                // Start receiving any data written by the connected client
                // asynchronously
                soc.BeginReceive(theSocPkt.dataBuffer, 0,
                                   theSocPkt.dataBuffer.Length,
                                   SocketFlags.None,
                                   workerCallback,
                                   theSocPkt);
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
示例#59
0
        public void WaitForData()
        {
            try
            {
                if  ( m_pfnCallBack == null )
                {
                    m_pfnCallBack = new AsyncCallback (OnDataReceived);
                }

                if (!this.pClientSocket.Connected)
                {
                    Server.logger.WriteLine(LogType.Debug, "SocketManager::WaitForData(): Server is not connected");
                    this.Disconnect();
                }

                if (this.pClientSocket == null) return;
                SocketPacket theSocPkt = new SocketPacket ();
                theSocPkt.thisSocket = this.pClientSocket;
                // Start listening to the data asynchronously
                m_result = this.pClientSocket.BeginReceive (theSocPkt.dataBuffer,
                    0, theSocPkt.dataBuffer.Length,
                    SocketFlags.None,
                    m_pfnCallBack,
                    theSocPkt);
            }
            catch(SocketException se)
            {
                Server.logger.WriteLine(LogType.Debug, "SocketManager::WaitForData(): SocketException: " + se.Message);
                this.Disconnect();

            }
            catch(Exception ex)
            {
                Server.logger.WriteLine(LogType.Debug, "SocketManager::WaitForData(): Exception: " + ex.Message);
                Console.WriteLine(ex.ToString());
            }
        }
示例#60
0
		// Start waiting for data from the client
		private void WaitForData(System.Net.Sockets.Socket soc, int clientNumber)
		{
			try
			{
				if  ( pfnWorkerCallBack == null )
				{		
					// Specify the call back function which is to be 
					// invoked when there is any write activity by the 
					// connected client
					pfnWorkerCallBack = new AsyncCallback (OnDataReceived);
				}
				SocketPacket theSocPkt = new SocketPacket (soc, clientNumber);
				
				soc.BeginReceive (theSocPkt.dataBuffer, 0, 
					theSocPkt.dataBuffer.Length,
					SocketFlags.None,
					pfnWorkerCallBack,
					theSocPkt);
			}
			catch(SocketException se)
			{
				Console.WriteLine("dpslamServer/WaitForData(" + PortNumber.ToString() + ")/" + se.Message);
			}
		}