sock_test.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 1998-2001, 2004, 2007, 2008, 2012-2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: sock_test.c,v 1.55 2008/07/23 23:27:54 marka Exp $ */
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static void
}
static void
printf("my_send: %s task %p\n\t(sock %p, base %p, length %d, n %d, "
"result %d)\n",
}
}
static void
char buf[1024];
char host[256];
printf("Socket %s (sock %p, base %p, length %d, n %d, result %d)\n",
} else {
}
return;
}
/*
* Echo the data back.
*/
} else
} else {
printf("\r\nReceived: %.*s\r\n\r\n",
}
}
static void
printf("my_http_get: %s task %p\n\t(sock %p, base %p, length %d, "
"n %d, result %d)\n",
return;
}
}
static void
char buf[1024];
return;
}
/*
* Send a GET string, and set up to receive (and just display)
* the result.
*/
"Connection: Close\r\n\r\n");
} else
}
static void
printf("newcon %s (task %p, oldsock %p, newsock %p, result %d)\n",
/*
* Queue another listen on this socket.
*/
== ISC_R_SUCCESS);
/*
* Create a new task for this socket, and queue up a
* recv on it.
*/
== ISC_R_SUCCESS);
} else {
return;
}
}
static void
}
static char one[] = "1";
static char two[] = "2";
static char xso1[] = "so1";
static char xso2[] = "so2";
int
unsigned int workers;
int pf;
if (argc > 1) {
if (workers < 1)
workers = 1;
if (workers > 8192)
workers = 8192;
} else
workers = 2;
if (isc_net_probeipv6() == ISC_R_SUCCESS)
else
/*
* EVERYTHING needs a memory context.
*/
/*
* The task manager is independent (other than memory context)
*/
/*
* Timer manager depends only on the memory context as well.
*/
/*
* Open up a listener socket.
*/
in6a = in6addr_any;
} else {
}
&so1) == ISC_R_SUCCESS);
/*
* Queue up the first accept event.
*/
== ISC_R_SUCCESS);
/*
* Open up a socket that will connect to www.flame.org, port 80.
* Why not. :)
*/
else
&so2) == ISC_R_SUCCESS);
/*
* Detaching these is safe, since the socket will attach to the
* task for any outstanding requests.
*/
/*
* Wait a short while.
*/
#ifndef WIN32
sleep(10);
#else
Sleep(10000);
#endif
return (0);
}