The peritoneo-vaginal duct is an evagination of the peritoneum that is attached to the testis and obliterates as the testis descends into the scrotum. When luminal obliteration does not occur, there is a sac through which abdominal contents can herniate through the inguinal canal. 

When the opening is large enough to allow passage of fluid, the result is a communicating hydrocele.

When closure occurs proximally but fluid remains trapped distally, the result is a noncommunicating hydrocele*.

Repair of hydroceles is usually delayed until about 3 years old* because the connection to the peritoneal cavity may be very small and may have already closed or may be in the process of closing. The fluid in the hydrocele comes from the peritoneal cavity and is gradually absorbed if the communication has closed. If the hydrocele persists after this period of observation, surgical repair* is usually indicated.

Inguinal hernia vs Hydrocele

Inguinal hernia vs Hydrocele

Operative Pediatric Surgery 7º Ed - Lewis Spitz, Arnold G Coran - ISBN: 978-1-4441-6501-2

* P Mattei. Fundamentals of Pediatric Surgery.