public static GbxCall ReceiveCall(Socket in_socket, byte[] inHeader)
{
if (in_socket.Connected)
{
lock (in_socket)
{
// read response size and handle ...
byte[] bSize = new byte[4];
byte[] bHandle = new byte[4];
if (inHeader == null)
{
in_socket.Receive(bSize);
in_socket.Receive(bHandle);
}
else
{
Array.Copy(inHeader, 0, bSize, 0, 4);
Array.Copy(inHeader, 4, bHandle, 0, 4);
}
int size = BitConverter.ToInt32(bSize, 0);
int handle = BitConverter.ToInt32(bHandle, 0);
// receive response body ...
byte[] data = ReceiveRpc(in_socket, size);
// parse the response ...
GbxCall call = new GbxCall(handle, data);
return call;
}
}
else
{
throw new NotConnectedException();
}
}