Index: azure_iot_hub/trunk/ntshell/src/fdtable.c
===================================================================
--- azure_iot_hub/trunk/ntshell/src/fdtable.c	(revision 391)
+++ azure_iot_hub/trunk/ntshell/src/fdtable.c	(revision 399)
@@ -299,5 +299,5 @@
 ER shell_get_evts(struct fd_events *evts, TMO tmout)
 {
-	int count = 0;
+	int count;
 	SYSTIM prev, now;
 	FLGPTN flgptn;
@@ -315,4 +315,5 @@
 		waitptn = *((FLGPTN *)&evts->readfds) | *((FLGPTN *)&evts->errorfds);
 #endif
+		count = 0;
 		for (int fd = 0; fd < fd_table_count; fd++) {
 			fp = &fd_table[fd];
Index: azure_iot_hub/trunk/ntshell/src/socket_stub.c
===================================================================
--- azure_iot_hub/trunk/ntshell/src/socket_stub.c	(revision 391)
+++ azure_iot_hub/trunk/ntshell/src/socket_stub.c	(revision 399)
@@ -70,4 +70,5 @@
 
 #define SOCKET_TIMEOUT 2000000
+#define TCP_SOCKET_BUF_SIZE 512
 
 struct addrinfo {
@@ -363,10 +364,10 @@
 				return -ENOMEM;
 
-			socket->buf_size = 512 + 512;
+			socket->buf_size = TCP_SOCKET_BUF_SIZE + TCP_SOCKET_BUF_SIZE;
 			socket->buf = malloc(socket->buf_size);
 #ifdef _DEBUG
 			memset(socket->buf, 0, socket->buf_size);
 #endif
-			T_TCP_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp_callback };
+			T_TCP_CCEP ccep = { 0, socket->buf, TCP_SOCKET_BUF_SIZE, &socket->buf[TCP_SOCKET_BUF_SIZE], TCP_SOCKET_BUF_SIZE, (FP)socket_tcp_callback };
 			ret = tcp_cre_cep(cepid, &ccep);
 			if (ret != E_OK) {
@@ -410,10 +411,10 @@
 				return -ENOMEM;
 
-			socket->buf_size = 512 + 512;
+			socket->buf_size = TCP_SOCKET_BUF_SIZE + TCP_SOCKET_BUF_SIZE;
 			socket->buf = malloc(socket->buf_size);
 #ifdef _DEBUG
 			memset(socket->buf, 0, socket->buf_size);
 #endif
-			T_TCP6_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp6_callback };
+			T_TCP6_CCEP ccep = { 0, socket->buf, TCP_SOCKET_BUF_SIZE, &socket->buf[TCP_SOCKET_BUF_SIZE], TCP_SOCKET_BUF_SIZE, (FP)socket_tcp6_callback };
 			ret = tcp6_cre_cep(cepid, &ccep);
 			if (ret != E_OK) {
@@ -522,10 +523,10 @@
 				return -ENOMEM;
 
-			socket->buf_size = 512 + 512;
+			socket->buf_size = TCP_SOCKET_BUF_SIZE + TCP_SOCKET_BUF_SIZE;
 			socket->buf = malloc(socket->buf_size);
 #ifdef _DEBUG
 			memset(socket->buf, 0, socket->buf_size);
 #endif
-			T_TCP_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp_callback };
+			T_TCP_CCEP ccep = { 0, socket->buf, TCP_SOCKET_BUF_SIZE, &socket->buf[TCP_SOCKET_BUF_SIZE], TCP_SOCKET_BUF_SIZE, (FP)socket_tcp_callback };
 			ret = tcp_cre_cep(cepid, &ccep);
 			if (ret != E_OK) {
@@ -560,10 +561,10 @@
 				return -ENOMEM;
 
-			socket->buf_size = 512 + 512;
+			socket->buf_size = TCP_SOCKET_BUF_SIZE + TCP_SOCKET_BUF_SIZE;
 			socket->buf = malloc(socket->buf_size);
 #ifdef _DEBUG
 			memset(socket->buf, 0, socket->buf_size);
 #endif
-			T_TCP6_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp6_callback };
+			T_TCP6_CCEP ccep = { 0, socket->buf, TCP_SOCKET_BUF_SIZE, &socket->buf[TCP_SOCKET_BUF_SIZE], TCP_SOCKET_BUF_SIZE, (FP)socket_tcp6_callback };
 			ret = tcp6_cre_cep(cepid, &ccep);
 			if (ret != E_OK) {
@@ -629,10 +630,10 @@
 				return -ENOMEM;
 
-			socket->buf_size = 512 + 512;
+			socket->buf_size = TCP_SOCKET_BUF_SIZE + TCP_SOCKET_BUF_SIZE;
 			socket->buf = malloc(socket->buf_size);
 #ifdef _DEBUG
 			memset(socket->buf, 0, socket->buf_size);
 #endif
-			T_TCP_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp_callback };
+			T_TCP_CCEP ccep = { 0, socket->buf, TCP_SOCKET_BUF_SIZE, &socket->buf[TCP_SOCKET_BUF_SIZE], TCP_SOCKET_BUF_SIZE, (FP)socket_tcp_callback };
 			ret = tcp_cre_cep(cepid, &ccep);
 			if (ret != E_OK) {
@@ -684,10 +685,10 @@
 				return -ENOMEM;
 
-			socket->buf_size = 512 + 512;
+			socket->buf_size = TCP_SOCKET_BUF_SIZE + TCP_SOCKET_BUF_SIZE;
 			socket->buf = malloc(socket->buf_size);
 #ifdef _DEBUG
 			memset(socket->buf, 0, socket->buf_size);
 #endif
-			T_TCP6_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp6_callback };
+			T_TCP6_CCEP ccep = { 0, socket->buf, TCP_SOCKET_BUF_SIZE, &socket->buf[TCP_SOCKET_BUF_SIZE], TCP_SOCKET_BUF_SIZE, (FP)socket_tcp6_callback };
 			ret = tcp6_cre_cep(cepid, &ccep);
 			if (ret != E_OK) {
