diff --git a/pelab/magent/UDP/UdpClient.cc b/pelab/magent/UDP/UdpClient.cc
index f8a1efe2e6ef2d65e22b503978a25d3c4cb3d285..3d3fa4ddfad6a2f776779fea41954ceb2e364ace 100644
--- a/pelab/magent/UDP/UdpClient.cc
+++ b/pelab/magent/UDP/UdpClient.cc
@@ -468,7 +468,7 @@ int main(int argc, char *argv[])
 		{
 			n = recvfrom(sd, msg, MAX_MSG, readFlags,
 			(struct sockaddr *) &echoServAddr, &echoLen);
-			if(n == EWOULDBLOCK)
+			if(n == -1 && errno == EWOULDBLOCK)
 			{
 				printf("Going to block in recvmsg\n");
 				exit(1);