sock_test.c revision 15a44745412679c30a6d022733925af70a38b715
/*
* Copyright (C) 1998-2000 Internet Software Consortium.
*
* 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.
*/
/* $Id: sock_test.c,v 1.44 2000/07/27 09:38:30 tale Exp $ */
#include <config.h>
#include <stdlib.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 {
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");
}
static void
printf("newcon %s (task %p, oldsock %p, newsock %p, result %d)\n",
/*
* Queue another listen on this socket.
*/
/*
* Create a new task for this socket, and queue up a
* recv on it.
*/
== ISC_R_SUCCESS);
} else {
return;
}
}
static void
}
int
unsigned int workers;
int pf;
if (argc > 1)
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.
*/
sleep(10);
return (0);
}