refactoring

Moved packet I/O into io.h.