Answer the question
In order to leave comments, you need to log in
Socket issue?
I want to implement the following functionality in a client-server application:
the client cools down the data to the server, and the server immediately after receiving the data transfers the number of bytes received to the client.
Server:
using (SocketEx socket = new SocketEx((IntPtr)state))<br>
{<br>
byte[] data = socket.Receive();<br>
socket.Send(BitConverter.GetBytes(data.Length)); <br>
}<br>
public int Send(byte[] data)<br>
{<br>
int count = socket.Send(data);<br>
byte[] response = socket.Receive();<br>
if (response != null && response.Length == 4)<br>
{<br>
return BitConverter.ToInt32(response, 0);<br>
}<br>
return -1;<br>
}<br>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question