Socket programming (C#) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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??)

27th Jun 2018, 6:31 AM
Sogand katuzian
1 Answer
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.
18th Jul 2018, 3:38 PM
John
John - avatar