I assume that you are familiar with vector and cross product in three dimension.
A line is defined by two points x_1, x_2:
where s is a variable.
The normal vector of skew lines l_1 (x_1,x_2) and l_2 (x_3,x_4) is the cross product of vectors (x_2-x_1) and (x_4-x_3)
and normalize it, we get
so the distance between line l_1 and line l_2 is
Easy? For more informations about vector and geometry, please refer to