sock_test.c revision c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840e
/*
* Copyright (C) 2004, 2007, 2008, 2012, 2013 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.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 {
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.
*/
== ISC_R_SUCCESS);
/*
* 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) {
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);
}