[Feature][ZXW-130]merge P50U02 version

Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I4f29ec5bb7c59385f23738d2b7ca84e67c100f69
diff --git a/ap/app/socket_demo/socket_main.c b/ap/app/socket_demo/socket_main.c
index 93225ea..c3031a3 100755
--- a/ap/app/socket_demo/socket_main.c
+++ b/ap/app/socket_demo/socket_main.c
@@ -57,7 +57,7 @@
 {

 	printf("Usage: %s\n", Opt);

 	printf("sock_create:type        create a new socket(eg. sock_create:1)\n");

-	printf("sock_createclient:type,addr       create a new client socket(eg. sock_createclient:1,/var/sockclient)\n");

+	printf("sock_createclient:type,addr,data       create a new client socket(eg. sock_createclient:1,/var/sockclient,data)\n");

 	printf("sock_createserver:type,addr,backlog       create a new server socket(eg. sock_createserver:1,/var/sockserver,30)\n");

 	printf("sock_bind:fd,addr        socket bind(eg. sock_bind:fd,/var/sockclient)\n");

 	printf("sock_listen:fd,backlog   socket listen(eg. sock_listen:fd,30)\n");

@@ -824,6 +824,11 @@
 		printf("socket_bind: anonymous socket\n");

 		my_addr.sun_path[0] = '\0';

 	}

+

+	if(access(paddr,F_OK))

+	{

+		unlink(paddr);//ɾ³ý¸ÃÎļþ	

+	}

 	

 	if(bind(sockfd, (struct sockaddr*)&my_addr, sizeof(my_addr)) == 0){

 		printf("socket°ó¶¨³É¹¦ \n");

@@ -952,14 +957,15 @@
 

 	if(at_tok_nextstr(&data, &pdata) < 0) {

 		printf("socket_send:at_tok_nextstr error\n");

+		return -1;

 	}

 

 	printf("socket_send: sockfd=%d, pdata=%s \n", sockfd, pdata);

 	

 	len = send(sockfd, pdata, strlen(pdata), 0);

 	

-	if(len >= 0){

-		printf("socket_send sucess, len=%d \n", len);

+	if(len > 0){

+		printf("socket_send sucess, data=%s, len=%d \n", pdata, len);

 	}else{

 		printf("socket_send failed, error: %s(errno: %d) \n", strerror(errno), errno);

 	}

@@ -984,10 +990,12 @@
 

 	if(at_tok_nextstr(&data, &paddr) < 0) {

 		printf("socket_sendto:at_tok_nextstr error\n");

+		return -1;

 	}

 	

 	if(at_tok_nextstr(&data, &pdata) < 0) {

 		printf("socket_sendto:at_tok_nextstr error\n");

+		return -1;

 	}

 

 	printf("socket_sendto: sockfd=%d, addr=%s \n", sockfd, paddr);

@@ -1012,7 +1020,7 @@
 	len = sendto(sockfd, pdata, strlen(pdata), 0, &other_addr, sizeof(other_addr));

 

 	if(len >= 0){

-		printf("socket_sendto sucess, len=%d \n", len);

+		printf("socket_sendto sucess, data=%s, len=%d \n", pdata, len);

 	}else{

 		printf("socket_sendto failed, error: %s(errno: %d) \n", strerror(errno), errno);

 	}

@@ -1034,13 +1042,14 @@
 

 	if(at_tok_nextstr(&data, &pdata) < 0) {

 		printf("socket_write:at_tok_nextstr error\n");

+		return -1;

 	}

 

 	printf("socket_write: sockfd=%d, pdata=%s \n", sockfd, pdata);

 		

 	len = write(sockfd, pdata, strlen(pdata));

-	if(len >= 0){

-		printf("socket_write sucess, len=%d \n", len);

+	if(len > 0){

+		printf("socket_write sucess, data=%s, len=%d \n", pdata, len);

 	}else{

 		printf("socket_write failed, error: %s(errno: %d) \n", strerror(errno), errno);

 	}

@@ -1064,8 +1073,10 @@
 	printf("socket_recv: sockfd=%d \n", sockfd);

 

 	len = recv(sockfd, pdata, sizeof(pdata), 0);

-	if(len >= 0){

-		printf("recv sucess, len=%d \n", len);

+	if(len > 0){

+		printf("recv sucess, data=%s, len=%d \n", pdata, len);

+	}else if(len == 0){

+		printf("client is close! \n");

 	}else{

 		printf("recv failed, error: %s(errno: %d) \n", strerror(errno), errno);

 	}

@@ -1089,8 +1100,11 @@
 	printf("socket_recvfrom: sockfd=%d \n", sockfd);

 

 	len = recvfrom(sockfd, pdata, sizeof(pdata)-1, 0, (struct sockaddr*)&other_addr, sizeof(other_addr));

-	if(len >= 0){

+	if(len > 0){

 		printf("recvfrom sucess:  other_addr.sun_path=%s\n", other_addr.sun_path);

+		printf("data=%s, len=%d\n", pdata, len);

+	}else if(len == 0){

+		printf("client is close! \n");

 	}else{

 		printf("recvfrom failed, error: %s(errno: %d) \n", strerror(errno), errno);

 	}

@@ -1113,8 +1127,10 @@
 	printf("socket_read: sockfd=%d \n", sockfd);

 

 	len = read(sockfd, pdata, sizeof(pdata));

-	if(len >= 0){

-		printf("read sucess, len=%d \n", len);

+	if(len > 0){

+		printf("read sucess, data=%s, len=%d \n", pdata, len);

+	}else if(len == 0){

+		printf("client is close! \n");

 	}else{

 		printf("read failed, error: %s(errno: %d) \n", strerror(errno), errno);

 	}