Sign in to follow this  
Followers 0
dragan

Sending byte array over TCP to Java client

1 post in this topic

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?

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0