Hi,
I'm developing a server-client application.
The server is done in Java (PC) and the client in Basic4Android (Android).
I'm having trouble with the following implementation:
Now the byte array is delivered in multiple packets of different lengths in the NewData event. So to handle this properly, I should use the prefix method. The problem is that i don't know how to implement this method into Java.
Erel, is there any way you could elaborate on how I would implement the prefix mode on the above java code? (buffer contains the raw bytes of the bitmap.)
Regards,
Tomas
EDIT:
Can i achieve the following for this:
I'm developing a server-client application.
The server is done in Java (PC) and the client in Basic4Android (Android).
I'm having trouble with the following implementation:
Server grabs bitmap -> raw bytes -> TCP -> Client (Async Streams _NewData)
Now the byte array is delivered in multiple packets of different lengths in the NewData event. So to handle this properly, I should use the prefix method. The problem is that i don't know how to implement this method into Java.
B4X:
OutputStream os = socket.getOutputStream();
os.write(buffer);
os.flush();
Erel, is there any way you could elaborate on how I would implement the prefix mode on the above java code? (buffer contains the raw bytes of the bitmap.)
Regards,
Tomas
EDIT:
Can i achieve the following for this:
B4X:
/**
* Sends a screenshot to the client
* @param message
* @throws IOException
*/
public void sendScreenshot(byte[] buffer) throws IOException {
OutputStream os = socket.getOutputStream();
os.write(buffer.length + 1);
os.write((byte) 0);
os.write(buffer, 0, buffer.length);
os.flush();
}
Last edited: