How to get all the byte data(generic bytedata octet-stream) of a frame in a single request(socket)

After connecting to a camera, when i open the socket to receive frame data in a byte array, Problem is, I am getting that byte array in chunks, which is time consuming. Is there a way with which i can ask the imageserver to send me all the byte array of the frame at once? So that i don’t have to loop over it? I went through the VideoViewer sample app where you are getting the byte array in chunks and with a do while loop, you are filling the byte array until you get all the data. Thats a good way but it is not applicable in my scenario, i want the data to come at once, I am used to using things like OpenCV’s VideoCapture object where there is a vc.grab() that grabs an entire frame at a time.

In the TCPVideoViewer sample, in ImageServerConnection.cs line 332 there is a variable

int maxbuf = 1024 * 64;

it governs the size of buffering in the TCP. If you change this might this be what you need to achieve what you need?

Yes i already tried that. My content length is ~321922 but when i set the max buf size to the content length it only returns ~25000, for the rest of the array i have to call it in a loop which i want to avoid

Try out setting the ReceiveBufferSize on the socket that is created.

https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.receivebuffersize?view=netframework-4.7.2