1998-12-12 20:48:14 +00:00
|
|
|
/*
|
2000-02-03 23:08:31 +00:00
|
|
|
* Copyright (C) 1998, 1999, 2000 Internet Software Consortium.
|
1998-12-12 20:48:14 +00:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
|
|
|
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
|
|
|
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
|
|
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
|
|
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
1998-11-03 00:54:47 +00:00
|
|
|
|
1998-12-12 19:25:20 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
1998-11-03 00:54:47 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
1998-11-15 11:48:21 +00:00
|
|
|
#include <string.h>
|
1998-11-03 00:54:47 +00:00
|
|
|
|
|
|
|
#include <isc/assertions.h>
|
1999-01-06 20:26:18 +00:00
|
|
|
#include <isc/error.h>
|
1998-12-11 20:38:46 +00:00
|
|
|
#include <isc/mem.h>
|
1998-11-03 00:54:47 +00:00
|
|
|
#include <isc/task.h>
|
|
|
|
#include <isc/thread.h>
|
|
|
|
#include <isc/result.h>
|
|
|
|
#include <isc/socket.h>
|
1998-12-05 00:28:13 +00:00
|
|
|
#include <isc/timer.h>
|
1999-07-15 20:16:48 +00:00
|
|
|
#include <isc/net.h>
|
1998-11-15 11:48:21 +00:00
|
|
|
|
1999-05-31 20:56:54 +00:00
|
|
|
isc_mem_t *mctx;
|
|
|
|
isc_taskmgr_t *manager;
|
1998-11-06 01:45:35 +00:00
|
|
|
|
1998-12-16 02:05:38 +00:00
|
|
|
static void my_send(isc_task_t *task, isc_event_t *event);
|
|
|
|
static void my_recv(isc_task_t *task, isc_event_t *event);
|
1998-11-26 00:10:33 +00:00
|
|
|
|
1998-12-16 02:05:38 +00:00
|
|
|
static void
|
1998-12-13 23:45:21 +00:00
|
|
|
my_shutdown(isc_task_t *task, isc_event_t *event)
|
1998-11-03 00:54:47 +00:00
|
|
|
{
|
|
|
|
char *name = event->arg;
|
|
|
|
|
|
|
|
printf("shutdown %s (%p)\n", name, task);
|
|
|
|
fflush(stdout);
|
|
|
|
isc_event_free(&event);
|
1998-11-06 01:45:35 +00:00
|
|
|
}
|
|
|
|
|
1998-12-16 02:05:38 +00:00
|
|
|
static void
|
1998-12-13 23:45:21 +00:00
|
|
|
my_recv(isc_task_t *task, isc_event_t *event)
|
1998-11-26 00:10:33 +00:00
|
|
|
{
|
1998-12-13 23:45:21 +00:00
|
|
|
isc_socket_t *sock;
|
|
|
|
isc_socketevent_t *dev;
|
|
|
|
isc_region_t region;
|
1998-11-26 00:10:33 +00:00
|
|
|
char buf[1024];
|
1999-08-28 04:29:04 +00:00
|
|
|
char host[256];
|
1998-11-26 00:10:33 +00:00
|
|
|
|
|
|
|
sock = event->sender;
|
1998-12-13 23:45:21 +00:00
|
|
|
dev = (isc_socketevent_t *)event;
|
1998-11-26 00:10:33 +00:00
|
|
|
|
|
|
|
printf("Socket %s (sock %p, base %p, length %d, n %d, result %d)\n",
|
|
|
|
(char *)(event->arg), sock,
|
|
|
|
dev->region.base, dev->region.length,
|
|
|
|
dev->n, dev->result);
|
1999-08-28 04:29:04 +00:00
|
|
|
if (dev->address.type.sa.sa_family == AF_INET6) {
|
|
|
|
inet_ntop(AF_INET6, &dev->address.type.sin6.sin6_addr,
|
|
|
|
host, sizeof (host));
|
|
|
|
printf("\tFrom: %s port %d\n", host,
|
|
|
|
ntohs(dev->address.type.sin6.sin6_port));
|
|
|
|
} else {
|
|
|
|
inet_ntop(AF_INET, &dev->address.type.sin.sin_addr,
|
|
|
|
host, sizeof (host));
|
|
|
|
printf("\tFrom: %s port %d\n", host,
|
|
|
|
ntohs(dev->address.type.sin.sin_port));
|
|
|
|
}
|
1998-11-26 00:10:33 +00:00
|
|
|
|
|
|
|
if (dev->result != ISC_R_SUCCESS) {
|
|
|
|
isc_socket_detach(&sock);
|
|
|
|
|
1999-06-09 23:30:46 +00:00
|
|
|
isc_mem_put(mctx, dev->region.base,
|
1998-12-18 22:02:41 +00:00
|
|
|
dev->region.length);
|
1998-11-26 00:10:33 +00:00
|
|
|
isc_event_free(&event);
|
|
|
|
|
1999-05-22 10:42:55 +00:00
|
|
|
isc_task_shutdown(task);
|
1998-12-16 02:05:38 +00:00
|
|
|
return;
|
1998-11-26 00:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Echo the data back
|
|
|
|
*/
|
1999-05-25 23:18:16 +00:00
|
|
|
if (strcmp(event->arg, "so2") != 0) {
|
1998-11-26 00:10:33 +00:00
|
|
|
region = dev->region;
|
1999-03-30 06:37:00 +00:00
|
|
|
sprintf(buf, "\r\nReceived: %.*s\r\n\r\n",
|
1999-07-28 21:30:37 +00:00
|
|
|
(int)dev->n, (char *)region.base);
|
1999-06-09 23:30:46 +00:00
|
|
|
region.base = isc_mem_get(mctx, strlen(buf) + 1);
|
1998-11-26 00:10:33 +00:00
|
|
|
region.length = strlen(buf) + 1;
|
1999-01-09 02:39:39 +00:00
|
|
|
strcpy((char *)region.base, buf); /* strcpy is safe */
|
1998-11-26 00:10:33 +00:00
|
|
|
isc_socket_send(sock, ®ion, task, my_send, event->arg);
|
|
|
|
} else {
|
|
|
|
region = dev->region;
|
1999-03-30 06:37:00 +00:00
|
|
|
printf("\r\nReceived: %.*s\r\n\r\n",
|
1999-07-28 21:30:37 +00:00
|
|
|
(int)dev->n, (char *)region.base);
|
1998-11-26 00:10:33 +00:00
|
|
|
}
|
|
|
|
|
1999-07-28 21:30:37 +00:00
|
|
|
isc_socket_recv(sock, &dev->region, 1, task, my_recv, event->arg);
|
1998-11-26 00:10:33 +00:00
|
|
|
|
|
|
|
isc_event_free(&event);
|
|
|
|
}
|
|
|
|
|
1998-12-16 02:05:38 +00:00
|
|
|
static void
|
1998-12-13 23:45:21 +00:00
|
|
|
my_send(isc_task_t *task, isc_event_t *event)
|
1998-11-11 00:43:14 +00:00
|
|
|
{
|
1998-12-13 23:45:21 +00:00
|
|
|
isc_socket_t *sock;
|
|
|
|
isc_socketevent_t *dev;
|
1998-11-11 00:43:14 +00:00
|
|
|
|
|
|
|
sock = event->sender;
|
1998-12-13 23:45:21 +00:00
|
|
|
dev = (isc_socketevent_t *)event;
|
1998-11-11 00:43:14 +00:00
|
|
|
|
|
|
|
printf("my_send: %s task %p\n\t(sock %p, base %p, length %d, n %d, result %d)\n",
|
|
|
|
(char *)(event->arg), task, sock,
|
|
|
|
dev->region.base, dev->region.length,
|
|
|
|
dev->n, dev->result);
|
|
|
|
|
1999-05-25 23:18:16 +00:00
|
|
|
if (dev->result != ISC_R_SUCCESS) {
|
|
|
|
isc_socket_detach(&sock);
|
|
|
|
isc_task_shutdown(task);
|
|
|
|
}
|
|
|
|
|
1999-06-09 23:30:46 +00:00
|
|
|
isc_mem_put(mctx, dev->region.base, dev->region.length);
|
1998-11-11 00:43:14 +00:00
|
|
|
|
|
|
|
isc_event_free(&event);
|
|
|
|
}
|
1998-11-26 00:10:33 +00:00
|
|
|
|
1998-12-16 02:05:38 +00:00
|
|
|
static void
|
1998-12-13 23:45:21 +00:00
|
|
|
my_http_get(isc_task_t *task, isc_event_t *event)
|
1998-11-10 11:37:54 +00:00
|
|
|
{
|
1998-12-13 23:45:21 +00:00
|
|
|
isc_socket_t *sock;
|
|
|
|
isc_socketevent_t *dev;
|
1998-11-10 11:37:54 +00:00
|
|
|
|
|
|
|
sock = event->sender;
|
1998-12-13 23:45:21 +00:00
|
|
|
dev = (isc_socketevent_t *)event;
|
1998-11-10 11:37:54 +00:00
|
|
|
|
1998-11-26 00:10:33 +00:00
|
|
|
printf("my_http_get: %s task %p\n\t(sock %p, base %p, length %d, n %d, result %d)\n",
|
|
|
|
(char *)(event->arg), task, sock,
|
1998-11-10 11:37:54 +00:00
|
|
|
dev->region.base, dev->region.length,
|
|
|
|
dev->n, dev->result);
|
1998-11-26 00:10:33 +00:00
|
|
|
|
1999-05-25 23:18:16 +00:00
|
|
|
if (dev->result != ISC_R_SUCCESS) {
|
|
|
|
isc_socket_detach(&sock);
|
|
|
|
isc_task_shutdown(task);
|
|
|
|
isc_event_free(&event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-07-28 21:30:37 +00:00
|
|
|
isc_socket_recv(sock, &dev->region, 1, task, my_recv, event->arg);
|
1998-11-26 00:10:33 +00:00
|
|
|
|
|
|
|
isc_event_free(&event);
|
|
|
|
}
|
|
|
|
|
1998-12-16 02:05:38 +00:00
|
|
|
static void
|
1998-12-13 23:45:21 +00:00
|
|
|
my_connect(isc_task_t *task, isc_event_t *event)
|
1998-11-26 00:10:33 +00:00
|
|
|
{
|
1998-12-13 23:45:21 +00:00
|
|
|
isc_socket_t *sock;
|
|
|
|
isc_socket_connev_t *dev;
|
|
|
|
isc_region_t region;
|
1998-11-26 00:10:33 +00:00
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
sock = event->sender;
|
1998-12-13 23:45:21 +00:00
|
|
|
dev = (isc_socket_connev_t *)event;
|
1998-11-26 00:10:33 +00:00
|
|
|
|
|
|
|
printf("%s: Connection result: %d\n", (char *)(event->arg),
|
|
|
|
dev->result);
|
1998-11-10 11:37:54 +00:00
|
|
|
|
|
|
|
if (dev->result != ISC_R_SUCCESS) {
|
|
|
|
isc_socket_detach(&sock);
|
|
|
|
isc_event_free(&event);
|
1999-05-25 23:18:16 +00:00
|
|
|
isc_task_shutdown(task);
|
1998-12-16 02:05:38 +00:00
|
|
|
return;
|
1998-11-10 11:37:54 +00:00
|
|
|
}
|
|
|
|
|
1998-11-11 00:43:14 +00:00
|
|
|
/*
|
1998-11-26 00:10:33 +00:00
|
|
|
* Send a GET string, and set up to receive (and just display)
|
|
|
|
* the result.
|
1998-11-11 00:43:14 +00:00
|
|
|
*/
|
1999-09-02 20:52:13 +00:00
|
|
|
strcpy(buf, "GET / HTTP/1.1\r\nHost: www.flame.org\r\nConnection: Close\r\n\r\n");
|
1999-06-09 23:30:46 +00:00
|
|
|
region.base = isc_mem_get(mctx, strlen(buf) + 1);
|
1998-11-11 00:43:14 +00:00
|
|
|
region.length = strlen(buf) + 1;
|
1999-01-09 02:39:39 +00:00
|
|
|
strcpy((char *)region.base, buf); /* strcpy is safe */
|
1998-11-10 11:37:54 +00:00
|
|
|
|
1998-11-26 00:10:33 +00:00
|
|
|
isc_socket_send(sock, ®ion, task, my_http_get, event->arg);
|
1998-11-11 00:43:14 +00:00
|
|
|
|
1998-11-10 11:37:54 +00:00
|
|
|
isc_event_free(&event);
|
|
|
|
}
|
|
|
|
|
1998-12-16 02:05:38 +00:00
|
|
|
static void
|
1998-12-13 23:45:21 +00:00
|
|
|
my_listen(isc_task_t *task, isc_event_t *event)
|
1998-11-06 01:45:35 +00:00
|
|
|
{
|
|
|
|
char *name = event->arg;
|
1998-12-13 23:45:21 +00:00
|
|
|
isc_socket_newconnev_t *dev;
|
|
|
|
isc_region_t region;
|
|
|
|
isc_socket_t *oldsock;
|
1999-05-22 10:42:55 +00:00
|
|
|
isc_task_t *newtask;
|
1998-11-06 01:45:35 +00:00
|
|
|
|
1998-12-13 23:45:21 +00:00
|
|
|
dev = (isc_socket_newconnev_t *)event;
|
1998-11-10 11:37:54 +00:00
|
|
|
|
|
|
|
printf("newcon %s (task %p, oldsock %p, newsock %p, result %d)\n",
|
|
|
|
name, task, event->sender, dev->newsocket, dev->result);
|
1998-11-06 01:45:35 +00:00
|
|
|
fflush(stdout);
|
|
|
|
|
1998-11-10 11:37:54 +00:00
|
|
|
if (dev->result == ISC_R_SUCCESS) {
|
|
|
|
/*
|
|
|
|
* queue another listen on this socket
|
|
|
|
*/
|
|
|
|
isc_socket_accept(event->sender, task, my_listen, event->arg);
|
|
|
|
|
1999-06-09 23:30:46 +00:00
|
|
|
region.base = isc_mem_get(mctx, 20);
|
1998-11-11 00:43:14 +00:00
|
|
|
region.length = 20;
|
1998-11-10 11:37:54 +00:00
|
|
|
|
|
|
|
/*
|
1999-05-22 10:42:55 +00:00
|
|
|
* Create a new task for this socket, and queue up a
|
|
|
|
* recv on it.
|
1998-11-10 11:37:54 +00:00
|
|
|
*/
|
1999-05-22 10:42:55 +00:00
|
|
|
newtask = NULL;
|
2000-04-12 01:41:21 +00:00
|
|
|
RUNTIME_CHECK(isc_task_create(manager, 0, &newtask)
|
1999-05-22 10:42:55 +00:00
|
|
|
== ISC_R_SUCCESS);
|
1999-07-28 21:30:37 +00:00
|
|
|
isc_socket_recv(dev->newsocket, ®ion, 1,
|
1999-05-22 10:42:55 +00:00
|
|
|
newtask, my_recv, event->arg);
|
|
|
|
isc_task_detach(&newtask);
|
1998-11-10 11:37:54 +00:00
|
|
|
} else {
|
1998-12-05 00:28:13 +00:00
|
|
|
printf("detaching from socket %p\n", event->sender);
|
|
|
|
oldsock = event->sender;
|
|
|
|
|
|
|
|
isc_socket_detach(&oldsock);
|
|
|
|
|
1998-12-18 04:03:11 +00:00
|
|
|
isc_event_free(&event);
|
1998-12-16 02:05:38 +00:00
|
|
|
isc_task_shutdown(task);
|
|
|
|
return;
|
1998-11-10 11:37:54 +00:00
|
|
|
}
|
1998-11-10 01:56:44 +00:00
|
|
|
|
1998-11-10 11:37:54 +00:00
|
|
|
isc_event_free(&event);
|
1998-12-05 00:28:13 +00:00
|
|
|
}
|
|
|
|
|
1998-12-16 02:05:38 +00:00
|
|
|
static void
|
1998-12-13 23:45:21 +00:00
|
|
|
timeout(isc_task_t *task, isc_event_t *event)
|
1998-12-05 00:28:13 +00:00
|
|
|
{
|
1998-12-13 23:45:21 +00:00
|
|
|
isc_socket_t *sock = event->arg;
|
1998-12-05 00:28:13 +00:00
|
|
|
|
1998-12-11 21:09:34 +00:00
|
|
|
printf("Timeout, canceling IO on socket %p (task %p)\n", sock, task);
|
1998-12-05 00:28:13 +00:00
|
|
|
|
|
|
|
isc_socket_cancel(sock, NULL, ISC_SOCKCANCEL_ALL);
|
1998-12-13 23:45:21 +00:00
|
|
|
isc_timer_detach((isc_timer_t **)&event->sender);
|
1998-12-18 04:03:11 +00:00
|
|
|
isc_event_free(&event);
|
1998-11-03 00:54:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
1999-05-31 20:56:54 +00:00
|
|
|
isc_task_t *t1, *t2;
|
|
|
|
isc_timermgr_t *timgr;
|
|
|
|
isc_time_t expires;
|
1998-12-13 23:45:21 +00:00
|
|
|
isc_interval_t interval;
|
1999-05-31 20:56:54 +00:00
|
|
|
isc_timer_t *ti1;
|
1998-11-03 00:54:47 +00:00
|
|
|
unsigned int workers;
|
1998-12-13 23:45:21 +00:00
|
|
|
isc_socketmgr_t *socketmgr;
|
|
|
|
isc_socket_t *so1, *so2;
|
|
|
|
isc_sockaddr_t sockaddr;
|
1999-07-15 20:16:48 +00:00
|
|
|
struct in_addr ina;
|
|
|
|
struct in6_addr in6a;
|
|
|
|
isc_result_t result;
|
|
|
|
int pf;
|
1998-11-03 00:54:47 +00:00
|
|
|
|
|
|
|
if (argc > 1)
|
|
|
|
workers = atoi(argv[1]);
|
|
|
|
else
|
|
|
|
workers = 2;
|
|
|
|
printf("%d workers\n", workers);
|
|
|
|
|
1999-07-19 23:54:09 +00:00
|
|
|
if (isc_net_probeipv6() == ISC_R_SUCCESS)
|
1999-07-15 20:16:48 +00:00
|
|
|
pf = PF_INET6;
|
|
|
|
else
|
|
|
|
pf = PF_INET;
|
|
|
|
|
1999-05-31 20:56:54 +00:00
|
|
|
/*
|
|
|
|
* EVERYTHING needs a memory context.
|
|
|
|
*/
|
|
|
|
mctx = NULL;
|
1999-01-06 20:26:18 +00:00
|
|
|
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
1998-11-03 00:54:47 +00:00
|
|
|
|
1999-05-31 20:56:54 +00:00
|
|
|
/*
|
|
|
|
* The task manager is independent (other than memory context)
|
|
|
|
*/
|
|
|
|
manager = NULL;
|
1999-01-06 20:26:18 +00:00
|
|
|
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &manager) ==
|
|
|
|
ISC_R_SUCCESS);
|
1998-11-03 00:54:47 +00:00
|
|
|
|
1999-05-31 20:56:54 +00:00
|
|
|
/*
|
|
|
|
* Timer manager depends only on the memory context as well.
|
|
|
|
*/
|
|
|
|
timgr = NULL;
|
|
|
|
RUNTIME_CHECK(isc_timermgr_create(mctx, &timgr) == ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
t1 = NULL;
|
2000-04-12 01:41:21 +00:00
|
|
|
RUNTIME_CHECK(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
|
1999-05-31 20:56:54 +00:00
|
|
|
t2 = NULL;
|
2000-04-12 01:41:21 +00:00
|
|
|
RUNTIME_CHECK(isc_task_create(manager, 0, &t2) == ISC_R_SUCCESS);
|
1999-01-06 20:26:18 +00:00
|
|
|
RUNTIME_CHECK(isc_task_onshutdown(t1, my_shutdown, "1") ==
|
|
|
|
ISC_R_SUCCESS);
|
|
|
|
RUNTIME_CHECK(isc_task_onshutdown(t2, my_shutdown, "2") ==
|
|
|
|
ISC_R_SUCCESS);
|
1998-11-03 00:54:47 +00:00
|
|
|
|
|
|
|
printf("task 1 = %p\n", t1);
|
|
|
|
printf("task 2 = %p\n", t2);
|
|
|
|
|
|
|
|
socketmgr = NULL;
|
1999-01-06 20:26:18 +00:00
|
|
|
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
|
1998-11-26 00:10:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* open up a listener socket
|
|
|
|
*/
|
1998-11-03 00:54:47 +00:00
|
|
|
so1 = NULL;
|
1999-07-15 20:16:48 +00:00
|
|
|
|
|
|
|
if (pf == PF_INET6) {
|
|
|
|
in6a = in6addr_any;
|
|
|
|
isc_sockaddr_fromin6(&sockaddr, &in6a, 5544);
|
|
|
|
} else {
|
|
|
|
ina.s_addr = INADDR_ANY;
|
|
|
|
isc_sockaddr_fromin(&sockaddr, &ina, 5544);
|
|
|
|
}
|
|
|
|
RUNTIME_CHECK(isc_socket_create(socketmgr, pf, isc_sockettype_tcp,
|
|
|
|
&so1) == ISC_R_SUCCESS);
|
|
|
|
result = isc_socket_bind(so1, &sockaddr);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
1999-01-06 20:26:18 +00:00
|
|
|
RUNTIME_CHECK(isc_socket_listen(so1, 0) == ISC_R_SUCCESS);
|
1998-11-10 11:37:54 +00:00
|
|
|
|
1998-11-26 00:10:33 +00:00
|
|
|
/*
|
|
|
|
* queue up the first accept event
|
|
|
|
*/
|
1999-01-06 20:26:18 +00:00
|
|
|
RUNTIME_CHECK(isc_socket_accept(so1, t1, my_listen,
|
|
|
|
"so1") == ISC_R_SUCCESS);
|
1998-12-05 00:28:13 +00:00
|
|
|
isc_time_settoepoch(&expires);
|
1998-12-18 04:03:11 +00:00
|
|
|
isc_interval_set(&interval, 10, 0);
|
1999-05-31 20:56:54 +00:00
|
|
|
ti1 = NULL;
|
1999-01-06 20:26:18 +00:00
|
|
|
RUNTIME_CHECK(isc_timer_create(timgr, isc_timertype_once, &expires,
|
|
|
|
&interval, t1, timeout, so1, &ti1) ==
|
|
|
|
ISC_R_SUCCESS);
|
1998-11-06 01:45:35 +00:00
|
|
|
|
1998-11-26 00:10:33 +00:00
|
|
|
/*
|
|
|
|
* open up a socket that will connect to www.flame.org, port 80.
|
|
|
|
* Why not. :)
|
|
|
|
*/
|
1998-11-03 00:54:47 +00:00
|
|
|
so2 = NULL;
|
1999-08-28 04:29:04 +00:00
|
|
|
ina.s_addr = inet_addr("204.152.184.97");
|
|
|
|
if (0 && pf == PF_INET6)
|
1999-07-15 20:16:48 +00:00
|
|
|
isc_sockaddr_v6fromin(&sockaddr, &ina, 80);
|
|
|
|
else
|
|
|
|
isc_sockaddr_fromin(&sockaddr, &ina, 80);
|
|
|
|
RUNTIME_CHECK(isc_socket_create(socketmgr, isc_sockaddr_pf(&sockaddr),
|
|
|
|
isc_sockettype_tcp,
|
1999-01-06 20:26:18 +00:00
|
|
|
&so2) == ISC_R_SUCCESS);
|
1999-08-28 04:29:04 +00:00
|
|
|
|
1999-07-07 02:02:52 +00:00
|
|
|
RUNTIME_CHECK(isc_socket_connect(so2, &sockaddr, t2,
|
1999-01-06 20:26:18 +00:00
|
|
|
my_connect, "so2") == ISC_R_SUCCESS);
|
1998-11-03 00:54:47 +00:00
|
|
|
|
1999-05-25 23:18:16 +00:00
|
|
|
/*
|
|
|
|
* Detaching these is safe, since the socket will attach to the
|
|
|
|
* task for any outstanding requests.
|
|
|
|
*/
|
1998-11-10 01:56:44 +00:00
|
|
|
isc_task_detach(&t1);
|
|
|
|
isc_task_detach(&t2);
|
|
|
|
|
1999-05-25 23:18:16 +00:00
|
|
|
/*
|
|
|
|
* wait a short while.
|
|
|
|
*/
|
1999-05-22 10:42:55 +00:00
|
|
|
sleep(10);
|
|
|
|
|
|
|
|
fprintf(stderr, "Destroying socket manager\n");
|
1998-11-03 00:54:47 +00:00
|
|
|
isc_socketmgr_destroy(&socketmgr);
|
1998-12-18 04:03:11 +00:00
|
|
|
|
1999-05-22 10:42:55 +00:00
|
|
|
fprintf(stderr, "Destroying timer manager\n");
|
1998-12-18 04:03:11 +00:00
|
|
|
isc_timermgr_destroy(&timgr);
|
|
|
|
|
1999-05-22 10:42:55 +00:00
|
|
|
fprintf(stderr, "Destroying task manager\n");
|
1998-11-03 00:54:47 +00:00
|
|
|
isc_taskmgr_destroy(&manager);
|
1998-12-18 04:03:11 +00:00
|
|
|
|
1998-11-03 00:54:47 +00:00
|
|
|
isc_mem_stats(mctx, stdout);
|
1998-12-18 19:14:37 +00:00
|
|
|
isc_mem_destroy(&mctx);
|
1998-11-03 00:54:47 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|