4. In the rectangular prism $A B C D-A_{1} B_{1} C_{1} D_{1}$, $A B=$ $A A_{1}=4, A D=3$, then the distance between the skew lines $A_{1} D$ and $B_{1} D_{1}$ is $\qquad$ .
4. $\frac{6 \sqrt{34}}{17}$.

Solution: Let the distance between $B_{1} D_{1}$ and $A_{1} D$ be $h$, then the distance between $B_{1} D_{1}$ and the plane $A_{1} B D$ is also $h$,
Given that $A_{1} D=B D=5, A_{1} B=4 \sqrt{2}$,
The distance from $D$ to $A B$ is $d=\sqrt{17}, S_{\triangle A_{1} B D}=\frac{1}{2} \cdot d$.
$$
\begin{array}{l}
A_{1} B=2 \sqrt{34} . \\
\quad V_{B_{1}-A_{1} D B}=\frac{1}{3} \cdot S_{\triangle A_{1} B D} \cdot h=\frac{2 \sqrt{34}}{3} h, \\
V_{B_{1}-A_{1} D B}=V_{D-A_{1} B_{1} B}=\frac{1}{3} \cdot S_{\triangle A_{1} B_{1} B} \cdot A D=8 \\
\Rightarrow h=\frac{6 \sqrt{34}}{17} .
\end{array}
$$