started cleanup up the socket mess

removed unused #include + dependency

more formatting fixes + fixed users of ReceiveSocket

cleaned more stuff up (converted from references to pointers is one)

wip. started rewriting everything, not quite finished

got everything except SensorOutput done (I think...)

got everything compiling except for missing SensorReceiver

worked on implementing the logic. didn't finish

made everything compile and finished implementing SensorReceiver

pulling over Austin's mock time stuff

added IncrementMockTime

finished up and started on tests

remembered something else
diff --git a/aos/common/network/Socket.cpp b/aos/common/network/Socket.cpp
index 1ffc775..0366e7c 100644
--- a/aos/common/network/Socket.cpp
+++ b/aos/common/network/Socket.cpp
@@ -32,7 +32,9 @@
 
   return last_ret_ = 0;
 }
+
 Socket::Socket() : socket_(-1), last_ret_(2) {}
+
 Socket::~Socket() {
   close(socket_);
 }
@@ -45,28 +47,31 @@
   last_ret_ = 0;
 }
 
-int Socket::Recv(void *buf, int length) {
+int Socket::Receive(void *buf, int length) {
   const int ret = recv(socket_, static_cast<char *>(buf), length, 0);
   last_ret_ = (ret == -1) ? -1 : 0;
   return ret;
 }
-int Socket::Recv(void *buf, int length, long usec) {
-	timeval tv;
-	tv.tv_sec = 0;
-	tv.tv_usec = usec;
-	fd_set fds;
-	FD_ZERO(&fds);
-	FD_SET(socket_, &fds);
-	switch (select(FD_SETSIZE, &fds, NULL, NULL, &tv)) {
-		case 1:
-      return Recv(buf, length);
-		case 0:
-			return last_ret_ = 0;
-		default:
-			perror("select on socket to receive from failed");
-			return last_ret_ = -1;
-	}
+
+int Socket::Receive(void *buf, int length, time::Time timeout) {
+  timeval timeout_timeval = timeout.ToTimeval();
+  fd_set fds;
+  FD_ZERO(&fds);
+  FD_SET(socket_, &fds);
+  switch (select(FD_SETSIZE, &fds, NULL, NULL, &timeout_timeval)) {
+    case 1:
+      return Receive(buf, length);
+    case 0:
+      return last_ret_ = 0;
+    default:
+      if (errno == EINTR) {
+        return last_ret_ = 0;
+      }
+      LOG(FATAL, "select(FD_SETSIZE, %p, NULL, NULL, %p) failed with %d: %s\n",
+          &fds, &timeout_timeval, errno, strerror(errno));
+  }
 }
+
 int Socket::Send(const void *buf, int length) {
   const int ret = write(socket_,
                         lame_unconst(static_cast<const char *>(buf)), length);