sock_test.c revision ec5347e2c775f027573ce5648b910361aa926c01
/*
* Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2001 Internet Software Consortium.
*
* 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 ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC 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.51 2007/06/18 23:47:26 tbox 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 {
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);
}