Provisional DTLS 1.2 support.
[openssl.git] / apps / s_socket.c
index 380efdb1b9762d28e8bc9f32fe0e4d1c76470435..e0de63c8f1995cea7e7e5909080c2e736d945ea7 100644 (file)
@@ -284,7 +284,7 @@ static int init_client_ip(int *sock, unsigned char ip[4], int port, int type)
        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, int stype, unsigned char *context), unsigned char *context, int naccept)
        {
        int sock;
        char *name = NULL;
@@ -310,11 +310,13 @@ int do_server(int port, int type, int *ret, int (*cb)(char *hostname, int s, uns
                        }
                else
                        sock = accept_socket;
-               i=(*cb)(name,sock, context);
+               i=(*cb)(name,sock, type, context);
                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);