Synchronized network code, should be thread safe.