@Override protected void send(RadiusRequest req, int attempt) throws Exception { Socket sock = socket; if (socketAcct != null && req instanceof AccountingRequest) sock = socketAcct; RadiusFormat format = RadiusFormat.getInstance(); OutputStream out = sock.getOutputStream(); buffer_out.clear(); format.packPacket(req, "radsec", buffer_out, true); synchronized (out) { if (statusListener != null) statusListener.onBeforeSend(this, req); out.write(buffer_out.array(), 0, buffer_out.position()); if (statusListener != null) statusListener.onAfterSend(this); } }
protected RadiusResponse receive(RadiusRequest req) throws Exception { RadiusResponse res = null; DataInputStream in = new DataInputStream(socket.getInputStream()); synchronized (in) { if (statusListener != null) statusListener.onBeforeReceive(this); int code = RadiusFormat.readUnsignedByte(in); int identifier = RadiusFormat.readUnsignedByte(in); int length = RadiusFormat.readUnsignedShort(in); buffer_in.clear(); buffer_in.limit(in.read(buffer_in.array(), 0, length)); res = (RadiusResponse) PacketFactory.parseUDP(code, identifier, length, buffer_in, false); if (statusListener != null) statusListener.onAfterReceive(this, res); } return res; }