Flux of magnetic field not zero Consider the magnetic part of a single electromagnetic wave in empty space, propagating along the $x$-axis of some reference frame. If we take as surface a cylinder with the axis along $x$ and height $L < \lambda /2$ (where $\lambda$ is the wavelenght) placed in a way that it is only crossed by upward (or downward) pointing $\textbf{B}$ vectors, and then we calculate the flux of B through this surface, how do we possibly get zero? The magnetic field is outgoing from the surface, so the flux should be positive.

My solution
I thought of a way to solve this apparent paradox but I am not sure about it, so I ask. My solution is that, since B is contained in a plane, and the intersection between this plane and the surface of the cylinder is a line, the surface integral to calculate the flux is zero because B is different from zero only in a region of negligible measure, namely a line with respect to a surface (I am thinking of Lebesgue integration).
Is my view correct?
 A: The picture you posted in the comments is misleading.From the picture it looks like the magnetic field originates from the X-axis while increasing towards the Y-axis.
That is not true ,the magnetic field is everywhere in the X-Y plane ,so if the magnetic field penetrates the Gaussian surface at lets say $y=a$ ,it will also penetrate at $y=-a$,making incoming flux equal to outgoing flux.
A: I think I understand what is confusing you.

The diagram you see is not a diagram related to the three axes of space $(x,y,z)$.  
That diagram gives you the direction and magnitude of the electric and magnetic field at each point along the x-axis with say $y=0$ and $z =0$.
So the three axes are $(x,E,B)$ 
You cannot draw a Gaussian surface using the diagram below.
To draw a Gaussian surface you would need to have the three spacial axes and have the Gaussian surface enclose a volume.  
A: The magnetic field is a solenoidal vector field which means that the total flux of any closed surface is zero, so it can't always be outgoing from the surface. If the flux is outgoing for almost the whole cylinder, the flux also has to be ingoing for some other part such that the total is zero. If you have any vector field and take the curl of that, the result will be a vector field that is solenoidal. A silly example would be to take $\vec F=(z,x,y)$ and take the curl of that to be your B - field. The curl woulf then be $\mathbf B=\nabla\times F=(1,1,1)$. Integrating this field over any closed surface will yield zero total flux.
A: Assuming you're talking about an electromagnetic plane wave, the magnetic field is not only outgoing from the surface. It may be outgoing on the upper half ($z > 0$), for example, but then it will be incoming on the lower half ($z < 0$), and these two contributions cancel out.
If you're not talking about a plane wave, you just Fourier transform the wave and then the same argument applies to each individual frequency component.
