Some bugfixes and test/debugging assist.

* Add some more debug log messages
* Fix copy/paste errors in function signatures
* Handle port 0 for the test server (system assigns a port at
  random -- record that port for the caller to inspect)
* In the server, change connection state to awake after sending
  a noop packet (to avoid sending multiple noops)
* Split handleGrabJobUnique in the server into several functions
  for modularity (helpful for subclasses)
* In the server, immediately wake up a connection on receipt of
  a pre_sleep packet if there is a waiting job (it may have arrived
  _after_ the most recent grab_job).

Change-Id: I0f2057bddfd6a13a0d2db08641ef51502ec06d9e