Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // вот метод отправки в службе:
- private void sendPacket(String reply, byte[] data) throws IOException {
- try {
- Log.logger.trace(this + "< " + reply + "; data.length = " + data.length);
- byte[] str = reply.getBytes(encodeCash);
- byte[] buf = new byte[1 + str.length + data.length + 8];
- buf[0 + 8] = (byte) str.length;
- System.arraycopy(str, 0, buf, 1 + 8, str.length);
- System.arraycopy(data, 0, buf, 1 + 8 + str.length, data.length);
- int size = buf.length - 4;
- buf[3] = (byte) (size & 0xff);
- buf[2] = (byte) ((size >> 8) & 0xff);
- buf[1] = (byte) ((size >> 16) & 0xff);
- buf[0] = (byte) ((size >> 24) & 0xff);
- buf[7] = (byte) (version & 0xff);
- buf[6] = (byte) ((version >> 8) & 0xff);
- buf[5] = (byte) ((version >> 16) & 0xff);
- buf[4] = (byte) ((version >> 24) & 0xff);
- bos.write(buf);
- bos.flush();
- os.flush();
- Log.logger.trace(this + "SendPacket - Ok");
- } catch (IOException e) {
- throw e;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement