Minor fixes after initial tests with apps/examples/udgram
This commit is contained in:
parent
e6f43d2ed8
commit
b437cadc03
@ -95,7 +95,6 @@ int server_main(int argc, char *argv[])
|
||||
socklen_t recvlen;
|
||||
int sockfd;
|
||||
int nbytes;
|
||||
int optval;
|
||||
int offset;
|
||||
|
||||
/* Create a new UDP socket */
|
||||
@ -107,15 +106,6 @@ int server_main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Set socket to reuse address */
|
||||
|
||||
optval = 1;
|
||||
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(int)) < 0)
|
||||
{
|
||||
printf("server: setsockopt SO_REUSEADDR failure: %d\n", errno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Bind the socket to a local address */
|
||||
|
||||
addrlen = strlen(CONFIG_EXAMPLES_UDGRAM_ADDR);
|
||||
@ -145,6 +135,13 @@ int server_main(int argc, char *argv[])
|
||||
nbytes = recvfrom(sockfd, inbuf, 1024, 0,
|
||||
(struct sockaddr*)&client, &recvlen);
|
||||
|
||||
if (nbytes < 0)
|
||||
{
|
||||
printf("server: %d. recv failed: %d\n", offset, errno);
|
||||
close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (recvlen < sizeof(sa_family_t) || recvlen > sizeof(struct sockaddr_un))
|
||||
{
|
||||
printf("server: %d. ERROR Received %d bytes from client with invalid length %d\n",
|
||||
@ -179,13 +176,6 @@ int server_main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (nbytes < 0)
|
||||
{
|
||||
printf("server: %d. recv failed: %d\n", offset, errno);
|
||||
close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (nbytes != SENDSIZE)
|
||||
{
|
||||
printf("server: %d. recv size incorrect: %d vs %d\n",
|
||||
|
Loading…
Reference in New Issue
Block a user