Code example for FileDescriptor

0
 
		Method setInt;
		int fdint = pfd.getFd();
		try { 
			setInt = FileDescriptor.class.getDeclaredMethod("setInt$",int.class);
			FileDescriptor fdtosend = new FileDescriptor();
 
			setInt.invoke(fdtosend,fdint);
 
			FileDescriptor[] fds = {fdtosend};
			mSocket.setFileDescriptorsForSend(fds);
 
			Log.d("Openvpn", "Sending FD tosocket: " + fdtosend + " " + fdint + "  " + pfd);
			// Trigger a send so we can close the fd on our side of the channel 
			// The API documentation fails to mention that it will not reset the file descriptor to 
			// be send and will happily send the file descriptor on every write ... 
			String cmd = String.format("needok '%s' %s\n", needed, "ok");
			managmentCommand(cmd);
 
			// Set the FileDescriptor to null to stop this mad behavior  
			mSocket.setFileDescriptorsForSend(null);