Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void ReceiveCallback(IAsyncResult AR)
- {
- Socket socket = (Socket)AR.AsyncState;
- try
- {
- int received = socket.EndReceive(AR);
- byte[] dataBuf = new byte[received];
- Array.Copy(_buffer, dataBuf, received);
- string text = Encoding.ASCII.GetString(dataBuf);
- Console.Write("Gauta: " + text);
- string response = string.Empty;
- if (text.ToLower() != "time")
- {
- response = "Neteisinga uzklausa";
- }
- else
- {
- response = DateTime.Now.ToLongTimeString();
- }
- byte[] data = Encoding.ASCII.GetBytes(response);
- socket.BeginSend(data, 0, data.Length, SocketFlags.None, new AsyncCallback(SendCallback), socket);
- }
- catch (Exception)
- {
- //string _clientIP = socket.RemoteEndPoint.ToString();
- //Console.WriteLine("Client Disconnected [" + _clientIP + " ]");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement