Listing 5. Server Accept Loop

while(1){
  if((s=accept(sock,0,0))<0)
    err_exit("Problem accepting");
  if((pid=fork())){
    close(s);
   }
   else {
     sbio=BIO_new_socket(s,BIO_NOCLOSE);
     ssl=SSL_new(ctx);
     SSL_set_bio(ssl,sbio,sbio);
     if((r=SSL_accept(ssl)<=0))
       berr_exit("SSL accept error");
     http_serve(ssl,s);
     exit(0);
   }
 }