Roundworms have only two bodily openings: a mouth and an anus. Roundworms are found as free-living nematodes, as well as endoparasites that live within the body of a host animal. Non-parasitic free-living nematodes are present in bodies of water, including deep ocean trenches and bodies of fresh water as well as in soil. They feed on any organic matter, particularly on decomposing matter. Eating decomposing organic matter allows the non-parasitic roundworm to contribute to the improvement of soil composition.
A parasitic roundworm's life cycle revolves around reaching the proper area within the host's body in order to obtain food. The host must be found and infected before the roundworm can maneuver themselves into the proper location inside the host to have access to food. A parasitic roundworm finds a host in a passive manner, rather than by searching. The host animal, in fact, typically finds the roundworm by eating foods that are contaminated with roundworm eggs. These eggs are found in the feces of infected animals, which spreads the roundworm infection into soil or other areas. When another animal eats something contaminated with these feces, the infection is spread to that animal. Dogs are the preferred host for roundworms, but other animals, including humans, can unknowingly ingest contaminated material and get infected as well.
Once the host animal has ingested the egg, the roundworm eggs hatch during the digestion process. Once the eggs hatch, the roundworms burrow out of the animal’s intestines to determine the suitability of the host animal. If the species of host animal is the right kind for the type of roundworm that has hatched, the resulting larvae then burrow to the animal’s lungs. Once inside the host animal's lungs, the roundworm may be coughed up and swallowed, allowing the roundworm to spend the remainder of its life cycle in the intestine, ingesting the host's partly digested food. In the event that the host animal is not suitable, the roundworm can feed on the tissues of the host animal.