How to get client request
#1

Hello all Smile Please tell me how can I get requests from the server and send requests to the server Last Chaos? For example I have the login window, and I want to cheat the customer by making it so that I missed to the list of servers. But when I try to read the client sends me when I press the enter button, I do not know what to send him back?

 

 

 

 

My C# code server:

namespace ConsoleApplication1
{
class Program
{
public static Socket sck, _client;
public static byte[] buffer;

static void Main(string[] args)
{
sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sck.Bind(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4001));
sck.Listen(4);

sck.BeginAccept(new AsyncCallback(OnAccept), null);
Console.WriteLine("Start");
Console.ReadKey();
}

private static void OnAccept(IAsyncResult result)
{
buffer = new byte[1024];

_client = sck.EndAccept(result);
Console.Write("Okay");
_client.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(OnReceive), null);
}

private static void OnReceive(IAsyncResult result)
{
int num = _client.EndReceive(result);
Array.Resize(ref buffer, num);
string temp = Encoding.Default.GetString(buffer);
Console.WriteLine(temp);
}
}
}



Messages In This Thread
[No subject] - by James123 - 05-10-2013, 02:10 PM
[No subject] - by HateMe - 05-10-2013, 02:47 PM
[No subject] - by James123 - 05-10-2013, 02:57 PM
[No subject] - by HateMe - 05-10-2013, 07:59 PM
[No subject] - by James123 - 05-11-2013, 06:29 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)