Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Sending byte array over TCP to Java client

$
0
0
Not actually for java, but for android client which is java based language.

I am trying to send array from autoit server to android client, and if someone is familiar with java programming, I'm using:
public byte[] readBytes() throws IOException {
InputStream in = socket.getInputStream();
DataInputStream dis = new DataInputStream(in);

int len = dis.readInt();
byte[] data = new byte[len];
if (len > 0) {
	 dis.readFully(data);
}
return data;
}

but in order to get this data from autoit server I can't use simple TcpSend() with just binary inside, I have to send the integer of the data size I'm sending 1st! but if I send separately: 1st integer with data size and then the data its not working.

p.s. sending simple text from autoit using TcpSend("string" & @lf) is working with:
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String cameString = in.readLine();
if(cameString != ""){
	//doo whatever with the cameString..
}
, but I need more, I would like for example to send array of strings, or image object, or stream audio... but for now I would just like to send the array of strings.

Can anyone help me? How should I form the TcpSend function in autoit so that java could recognize it as a valid array of bytes?

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>