Aims. We study the dynamics of gas and dust in a protoplanetary disk in the presence of embedded planets. We investigate the conditions for dust-gap formation in terms of particle size and planetary mass. We also monitor the amount of dust that is accreted by the planet relative to the amount of gas, which is an important parameter in determining the enrichment of solids in giant planets compared to the solid content of the central star. Methods. We use a new two-fluid hydrodynamics code to solve the flow equations for both gas and dust. For the gas, we use a Godunov-type scheme with an approximate Riemann solver (the Roe solver). The dust is treated as a pressureless fluid by essentially the same numerical method as is used for the gas. Results. We find that it only takes a planet of 0.05 Jupiter masses to open up a gap in a disk with a significant population of mm-sized particles. Dust particles larger than 150 mu m participate in gap formation. We also find that the formation of the gap severely slows down dust accretion compared to that in the gas. Therefore, it is not possible to enrich a newly formed giant planet in solids, if these solids are contained in particles with sizes from 150 mu m to approximately 10 cm.