/* Should we generate coredumps when we enounter an error (-c) */
static bool do_core= false;
/* connection to the server */
-static SOCKET sock;
+static memcached_socket_t sock;
/* Should the output from test failures be verbose or quiet? */
static bool verbose= false;
* Set the socket in nonblocking mode
* @return -1 if failure, the socket otherwise
*/
-static SOCKET set_noblock(void)
+static memcached_socket_t set_noblock(void)
{
#ifdef WIN32
u_long arg = 1;
* @param port the port number (or service) to connect to
* @return positive integer if success, -1 otherwise
*/
-static SOCKET connect_server(const char *hostname, const char *port)
+static memcached_socket_t connect_server(const char *hostname, const char *port)
{
struct addrinfo *ai= lookuphost(hostname, port);
sock= INVALID_SOCKET;
return sock;
}
-static ssize_t timeout_io_op(SOCKET fd, short direction, void *buf, size_t len)
+static ssize_t timeout_io_op(memcached_socket_t fd, short direction, void *buf, size_t len)
{
ssize_t ret;
extern memcached_binary_protocol_callback_st interface_v0_impl;
extern memcached_binary_protocol_callback_st interface_v1_impl;
-static SOCKET server_sockets[1024];
+static memcached_socket_t server_sockets[1024];
static int num_server_sockets= 0;
struct connection
* @param which identifying the event that occurred (not used)
* @param arg the connection structure for the client
*/
-static void drive_client(SOCKET fd, short which, void *arg)
+static void drive_client(memcached_socket_t fd, short which, void *arg)
{
(void)which;
struct connection *client= arg;
* @param which identifying the event that occurred (not used)
* @param arg the connection structure for the server
*/
-static void accept_handler(SOCKET fd, short which, void *arg)
+static void accept_handler(memcached_socket_t fd, short which, void *arg)
{
(void)which;
struct connection *server= arg;
/* accept new client */
struct sockaddr_storage addr;
socklen_t addrlen= sizeof(addr);
- SOCKET sock= accept(fd, (struct sockaddr *)&addr, &addrlen);
+ memcached_socket_t sock= accept(fd, (struct sockaddr *)&addr, &addrlen);
if (sock == INVALID_SOCKET)
{
for (struct addrinfo *next= ai; next; next= next->ai_next)
{
- SOCKET sock= socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ memcached_socket_t sock= socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (sock == INVALID_SOCKET)
{
perror("Failed to create socket");
#include <winsock2.h>
#include <ws2tcpip.h>
typedef short in_port_t;
+typedef SOCKET memcached_socket_t;
#else
-typedef int SOCKET;
+typedef int memcached_socket_t;
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
struct memcached_protocol_client_st {
memcached_protocol_st *root;
- SOCKET sock;
+ memcached_socket_t sock;
int error;
/* Linked list of data to send */
* @return the number of bytes transferred of -1 upon error
*/
static ssize_t default_recv(const void *cookie,
- SOCKET sock,
+ memcached_socket_t sock,
void *buf,
size_t nbytes)
{
* @return the number of bytes transferred of -1 upon error
*/
static ssize_t default_send(const void *cookie,
- SOCKET fd,
+ memcached_socket_t fd,
const void *buf,
size_t nbytes)
{
free(instance);
}
-struct memcached_protocol_client_st *memcached_protocol_create_client(struct memcached_protocol_st *instance, SOCKET sock)
+struct memcached_protocol_client_st *memcached_protocol_create_client(struct memcached_protocol_st *instance, memcached_socket_t sock)
{
struct memcached_protocol_client_st *ret= calloc(1, sizeof(*ret));
if (ret != NULL)
* or -1 upon error (errno should contain more information)
*/
typedef ssize_t (*memcached_protocol_recv_func)(const void *cookie,
- SOCKET fd,
+ memcached_socket_t fd,
void *buf,
size_t nbuf);
* or -1 upon error (errno should contain more information)
*/
typedef ssize_t (*memcached_protocol_send_func)(const void *cookie,
- SOCKET fd,
+ memcached_socket_t fd,
const void *buf,
size_t nbuf);
* @return NULL if allocation fails, otherwise an instance
*/
LIBMEMCACHED_API
-memcached_protocol_client_st *memcached_protocol_create_client(memcached_protocol_st *instance, SOCKET sock);
+memcached_protocol_client_st *memcached_protocol_create_client(memcached_protocol_st *instance, memcached_socket_t sock);
/**
* Destroy a client handle.
* @return the socket handle
*/
LIBMEMCACHED_API
-SOCKET memcached_protocol_client_get_socket(memcached_protocol_client_st *client);
+memcached_socket_t memcached_protocol_client_get_socket(memcached_protocol_client_st *client);
/**
* Get the error id socket attached to a client handle
uint32_t cursor_active;
in_port_t port;
int cached_errno;
- SOCKET fd;
+ memcached_socket_t fd;
uint32_t io_bytes_sent; /* # bytes sent since last read */
uint32_t server_failure_counter;
uint32_t weight;