I have an application that constantly fetches input in Java from a frame buffer and sends it over the wire to a C++ application.
I am having issues on the receiver side. I am trying to send one packet (or at least let TCP reconstruct it as a single packet) for each frame buffer. The frame buffer is getting splitted into multiple small packets on the receiving end.
The Java code is the following:
OutputStream os = clientSocket.getOutputStream(); FileInputStream fos = new FileInputStream("fb"); while (true) { int nb = fos.read(buff); if (nb <= 0) break; os.write(buff, 0, nb); } fos.close(); os.close(); On the client side, I am trying to read the same amount. nb and size are the same value here:
n = read(sockfd, buffer, size); while (n > 0) { // We have a new frame fprintf(stderr, "New frame: %d\n", n); n = read(sockfd, buffer, size); } The value of n that is printed is much smaller than size. It receives a lot of packets when I would hope the return from read() would be a packet of the size 'size' (or nb).
Does anyone please know why is that please?
Thank you very much for your help!