Implement TCP and UDP handling