+ 2
Socket programming (C#)
Hi everyone Does anybody know how we control the amount of input in Socket because the information form is in bytes type ?? I mean for example the client types “Hello” how server can find out the amount of hello’s code ? (How many bytes are waiting to enter through the socket??)
1 Resposta
0
There is a recursive call to CallBackAcceptTcpClient in there you end accepting TCP clients and that returns a TCP client, this is the client. You cast the TcpClient global instance to an int. (int)_TcpClient.AsyncResult; this gives the amount of bytes. By this point you should have a global byte buffer , this is what you pass in: TcpClient.BeginAcceptTcpClient(AsynchronousResult(delegate(ASyncREsult), byte[] buffer, object state, etc)
I can go deeper than this, sorry if this isn't clear, ask for more in-depth.