summaryrefslogtreecommitdiffstats
path: root/apps/s_socket.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2012-11-18 15:45:16 +0000
committerDr. Stephen Henson <steve@openssl.org>2012-11-18 15:45:16 +0000
commitb5cadfb564a604c0ba1c49984ac796cfd8310731 (patch)
tree0ced05d7234cca69b0c7be6ee74023a711141b65 /apps/s_socket.c
parentc4fc172240b867350967ee50734267c402450e19 (diff)
add -naccept <n> option to s_server to automatically exit after <n> connections
Diffstat (limited to 'apps/s_socket.c')
-rw-r--r--apps/s_socket.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/apps/s_socket.c b/apps/s_socket.c
index 6dd736af01..f73f1931e5 100644
--- a/apps/s_socket.c
+++ b/apps/s_socket.c
@@ -280,7 +280,7 @@ static int init_client_ip(int *sock, const unsigned char ip[4], int port,
return(1);
}
-int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, unsigned char *context), unsigned char *context)
+int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, unsigned char *context), unsigned char *context, int naccept)
{
int sock;
char *name = NULL;
@@ -310,7 +310,9 @@ int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, uns
if (name != NULL) OPENSSL_free(name);
if (type==SOCK_STREAM)
SHUTDOWN2(sock);
- if (i < 0)
+ if (naccept != -1)
+ naccept--;
+ if (i < 0 || naccept == 0)
{
SHUTDOWN2(accept_socket);
return(i);