Unix domain: More fixes. With these changes, apps/examples/ustream works

This commit is contained in:
Gregory Nutt 2015-01-28 08:39:48 -06:00
parent b7fa5a3359
commit 1c2cb493e6
2 changed files with 5 additions and 10 deletions

View File

@ -103,7 +103,7 @@ int client_main(int argc, char *argv[])
strncpy(myaddr.sun_path, CONFIG_EXAMPLES_USTREAM_ADDR, addrlen);
myaddr.sun_path[addrlen] = '\0';
printf("client: Connecting...\n");
printf("client: Connecting to %s...\n", CONFIG_EXAMPLES_USTREAM_ADDR);
addrlen += sizeof(sa_family_t) + 1;
ret = connect( sockfd, (struct sockaddr *)&myaddr, addrlen);
if (ret < 0)
@ -176,6 +176,7 @@ int client_main(int argc, char *argv[])
goto errout_with_socket;
}
printf("client: Terminating\n");
close(sockfd);
free(outbuf);
free(inbuf);

View File

@ -113,6 +113,8 @@ int server_main(int argc, char *argv[])
/* Listen for connections on the bound socket */
printf("server: Accepting connections on %s ...\n", CONFIG_EXAMPLES_USTREAM_ADDR);
if (listen(listensd, 5) < 0)
{
printf("server: listen failure %d\n", errno);
@ -121,7 +123,6 @@ int server_main(int argc, char *argv[])
/* Accept only one connection */
printf("server: Accepting connections on %s\n", CONFIG_EXAMPLES_USTREAM_ADDR);
acceptsd = accept(listensd, (struct sockaddr*)&myaddr, &addrlen);
if (acceptsd < 0)
{
@ -187,14 +188,7 @@ int server_main(int argc, char *argv[])
}
printf("server: Sent %d bytes\n", nbytessent);
/* If this platform only does abortive disconnects, then wait a bit to get the
* client side a change to receive the data.
*/
printf("server: Wait before closing\n");
sleep(60);
printf("server: Terminating\n");
close(listensd);
close(acceptsd);
free(buffer);