mostly working for single connection; commit before changing the way we use the built in tcp stuff, since it may be wrong.