Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/include/event2
File: util.h
/*
[0] Fix | Delete
* Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
[1] Fix | Delete
*
[2] Fix | Delete
* Redistribution and use in source and binary forms, with or without
[3] Fix | Delete
* modification, are permitted provided that the following conditions
[4] Fix | Delete
* are met:
[5] Fix | Delete
* 1. Redistributions of source code must retain the above copyright
[6] Fix | Delete
* notice, this list of conditions and the following disclaimer.
[7] Fix | Delete
* 2. Redistributions in binary form must reproduce the above copyright
[8] Fix | Delete
* notice, this list of conditions and the following disclaimer in the
[9] Fix | Delete
* documentation and/or other materials provided with the distribution.
[10] Fix | Delete
* 3. The name of the author may not be used to endorse or promote products
[11] Fix | Delete
* derived from this software without specific prior written permission.
[12] Fix | Delete
*
[13] Fix | Delete
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
[14] Fix | Delete
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
[15] Fix | Delete
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
[16] Fix | Delete
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
[17] Fix | Delete
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
[18] Fix | Delete
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
[19] Fix | Delete
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
[20] Fix | Delete
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
[21] Fix | Delete
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
[22] Fix | Delete
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[23] Fix | Delete
*/
[24] Fix | Delete
#ifndef EVENT2_UTIL_H_INCLUDED_
[25] Fix | Delete
#define EVENT2_UTIL_H_INCLUDED_
[26] Fix | Delete
[27] Fix | Delete
/** @file event2/util.h
[28] Fix | Delete
[29] Fix | Delete
Common convenience functions for cross-platform portability and
[30] Fix | Delete
related socket manipulations.
[31] Fix | Delete
[32] Fix | Delete
*/
[33] Fix | Delete
#include <event2/visibility.h>
[34] Fix | Delete
[35] Fix | Delete
#ifdef __cplusplus
[36] Fix | Delete
extern "C" {
[37] Fix | Delete
#endif
[38] Fix | Delete
[39] Fix | Delete
#include <event2/event-config.h>
[40] Fix | Delete
#ifdef EVENT__HAVE_SYS_TIME_H
[41] Fix | Delete
#include <sys/time.h>
[42] Fix | Delete
#endif
[43] Fix | Delete
#ifdef EVENT__HAVE_STDINT_H
[44] Fix | Delete
#include <stdint.h>
[45] Fix | Delete
#elif defined(EVENT__HAVE_INTTYPES_H)
[46] Fix | Delete
#include <inttypes.h>
[47] Fix | Delete
#endif
[48] Fix | Delete
#ifdef EVENT__HAVE_SYS_TYPES_H
[49] Fix | Delete
#include <sys/types.h>
[50] Fix | Delete
#endif
[51] Fix | Delete
#ifdef EVENT__HAVE_STDDEF_H
[52] Fix | Delete
#include <stddef.h>
[53] Fix | Delete
#endif
[54] Fix | Delete
#ifdef _MSC_VER
[55] Fix | Delete
#include <BaseTsd.h>
[56] Fix | Delete
#endif
[57] Fix | Delete
#include <stdarg.h>
[58] Fix | Delete
#ifdef EVENT__HAVE_NETDB_H
[59] Fix | Delete
#if !defined(_GNU_SOURCE)
[60] Fix | Delete
#define _GNU_SOURCE
[61] Fix | Delete
#endif
[62] Fix | Delete
#include <netdb.h>
[63] Fix | Delete
#endif
[64] Fix | Delete
[65] Fix | Delete
#ifdef _WIN32
[66] Fix | Delete
#include <winsock2.h>
[67] Fix | Delete
#ifdef EVENT__HAVE_GETADDRINFO
[68] Fix | Delete
/* for EAI_* definitions. */
[69] Fix | Delete
#include <ws2tcpip.h>
[70] Fix | Delete
#endif
[71] Fix | Delete
#else
[72] Fix | Delete
#ifdef EVENT__HAVE_ERRNO_H
[73] Fix | Delete
#include <errno.h>
[74] Fix | Delete
#endif
[75] Fix | Delete
#include <sys/socket.h>
[76] Fix | Delete
#endif
[77] Fix | Delete
[78] Fix | Delete
#include <time.h>
[79] Fix | Delete
[80] Fix | Delete
/* Some openbsd autoconf versions get the name of this macro wrong. */
[81] Fix | Delete
#if defined(EVENT__SIZEOF_VOID__) && !defined(EVENT__SIZEOF_VOID_P)
[82] Fix | Delete
#define EVENT__SIZEOF_VOID_P EVENT__SIZEOF_VOID__
[83] Fix | Delete
#endif
[84] Fix | Delete
[85] Fix | Delete
/**
[86] Fix | Delete
* @name Standard integer types.
[87] Fix | Delete
*
[88] Fix | Delete
* Integer type definitions for types that are supposed to be defined in the
[89] Fix | Delete
* C99-specified stdint.h. Shamefully, some platforms do not include
[90] Fix | Delete
* stdint.h, so we need to replace it. (If you are on a platform like this,
[91] Fix | Delete
* your C headers are now over 10 years out of date. You should bug them to
[92] Fix | Delete
* do something about this.)
[93] Fix | Delete
*
[94] Fix | Delete
* We define:
[95] Fix | Delete
*
[96] Fix | Delete
* <dl>
[97] Fix | Delete
* <dt>ev_uint64_t, ev_uint32_t, ev_uint16_t, ev_uint8_t</dt>
[98] Fix | Delete
* <dd>unsigned integer types of exactly 64, 32, 16, and 8 bits
[99] Fix | Delete
* respectively.</dd>
[100] Fix | Delete
* <dt>ev_int64_t, ev_int32_t, ev_int16_t, ev_int8_t</dt>
[101] Fix | Delete
* <dd>signed integer types of exactly 64, 32, 16, and 8 bits
[102] Fix | Delete
* respectively.</dd>
[103] Fix | Delete
* <dt>ev_uintptr_t, ev_intptr_t</dt>
[104] Fix | Delete
* <dd>unsigned/signed integers large enough
[105] Fix | Delete
* to hold a pointer without loss of bits.</dd>
[106] Fix | Delete
* <dt>ev_ssize_t</dt>
[107] Fix | Delete
* <dd>A signed type of the same size as size_t</dd>
[108] Fix | Delete
* <dt>ev_off_t</dt>
[109] Fix | Delete
* <dd>A signed type typically used to represent offsets within a
[110] Fix | Delete
* (potentially large) file</dd>
[111] Fix | Delete
*
[112] Fix | Delete
* @{
[113] Fix | Delete
*/
[114] Fix | Delete
#ifdef EVENT__HAVE_UINT64_T
[115] Fix | Delete
#define ev_uint64_t uint64_t
[116] Fix | Delete
#define ev_int64_t int64_t
[117] Fix | Delete
#elif defined(_WIN32)
[118] Fix | Delete
#define ev_uint64_t unsigned __int64
[119] Fix | Delete
#define ev_int64_t signed __int64
[120] Fix | Delete
#elif EVENT__SIZEOF_LONG_LONG == 8
[121] Fix | Delete
#define ev_uint64_t unsigned long long
[122] Fix | Delete
#define ev_int64_t long long
[123] Fix | Delete
#elif EVENT__SIZEOF_LONG == 8
[124] Fix | Delete
#define ev_uint64_t unsigned long
[125] Fix | Delete
#define ev_int64_t long
[126] Fix | Delete
#elif defined(EVENT_IN_DOXYGEN_)
[127] Fix | Delete
#define ev_uint64_t ...
[128] Fix | Delete
#define ev_int64_t ...
[129] Fix | Delete
#else
[130] Fix | Delete
#error "No way to define ev_uint64_t"
[131] Fix | Delete
#endif
[132] Fix | Delete
[133] Fix | Delete
#ifdef EVENT__HAVE_UINT32_T
[134] Fix | Delete
#define ev_uint32_t uint32_t
[135] Fix | Delete
#define ev_int32_t int32_t
[136] Fix | Delete
#elif defined(_WIN32)
[137] Fix | Delete
#define ev_uint32_t unsigned int
[138] Fix | Delete
#define ev_int32_t signed int
[139] Fix | Delete
#elif EVENT__SIZEOF_LONG == 4
[140] Fix | Delete
#define ev_uint32_t unsigned long
[141] Fix | Delete
#define ev_int32_t signed long
[142] Fix | Delete
#elif EVENT__SIZEOF_INT == 4
[143] Fix | Delete
#define ev_uint32_t unsigned int
[144] Fix | Delete
#define ev_int32_t signed int
[145] Fix | Delete
#elif defined(EVENT_IN_DOXYGEN_)
[146] Fix | Delete
#define ev_uint32_t ...
[147] Fix | Delete
#define ev_int32_t ...
[148] Fix | Delete
#else
[149] Fix | Delete
#error "No way to define ev_uint32_t"
[150] Fix | Delete
#endif
[151] Fix | Delete
[152] Fix | Delete
#ifdef EVENT__HAVE_UINT16_T
[153] Fix | Delete
#define ev_uint16_t uint16_t
[154] Fix | Delete
#define ev_int16_t int16_t
[155] Fix | Delete
#elif defined(_WIN32)
[156] Fix | Delete
#define ev_uint16_t unsigned short
[157] Fix | Delete
#define ev_int16_t signed short
[158] Fix | Delete
#elif EVENT__SIZEOF_INT == 2
[159] Fix | Delete
#define ev_uint16_t unsigned int
[160] Fix | Delete
#define ev_int16_t signed int
[161] Fix | Delete
#elif EVENT__SIZEOF_SHORT == 2
[162] Fix | Delete
#define ev_uint16_t unsigned short
[163] Fix | Delete
#define ev_int16_t signed short
[164] Fix | Delete
#elif defined(EVENT_IN_DOXYGEN_)
[165] Fix | Delete
#define ev_uint16_t ...
[166] Fix | Delete
#define ev_int16_t ...
[167] Fix | Delete
#else
[168] Fix | Delete
#error "No way to define ev_uint16_t"
[169] Fix | Delete
#endif
[170] Fix | Delete
[171] Fix | Delete
#ifdef EVENT__HAVE_UINT8_T
[172] Fix | Delete
#define ev_uint8_t uint8_t
[173] Fix | Delete
#define ev_int8_t int8_t
[174] Fix | Delete
#elif defined(EVENT_IN_DOXYGEN_)
[175] Fix | Delete
#define ev_uint8_t ...
[176] Fix | Delete
#define ev_int8_t ...
[177] Fix | Delete
#else
[178] Fix | Delete
#define ev_uint8_t unsigned char
[179] Fix | Delete
#define ev_int8_t signed char
[180] Fix | Delete
#endif
[181] Fix | Delete
[182] Fix | Delete
#ifdef EVENT__HAVE_UINTPTR_T
[183] Fix | Delete
#define ev_uintptr_t uintptr_t
[184] Fix | Delete
#define ev_intptr_t intptr_t
[185] Fix | Delete
#elif EVENT__SIZEOF_VOID_P <= 4
[186] Fix | Delete
#define ev_uintptr_t ev_uint32_t
[187] Fix | Delete
#define ev_intptr_t ev_int32_t
[188] Fix | Delete
#elif EVENT__SIZEOF_VOID_P <= 8
[189] Fix | Delete
#define ev_uintptr_t ev_uint64_t
[190] Fix | Delete
#define ev_intptr_t ev_int64_t
[191] Fix | Delete
#elif defined(EVENT_IN_DOXYGEN_)
[192] Fix | Delete
#define ev_uintptr_t ...
[193] Fix | Delete
#define ev_intptr_t ...
[194] Fix | Delete
#else
[195] Fix | Delete
#error "No way to define ev_uintptr_t"
[196] Fix | Delete
#endif
[197] Fix | Delete
[198] Fix | Delete
#ifdef EVENT__ssize_t
[199] Fix | Delete
#define ev_ssize_t EVENT__ssize_t
[200] Fix | Delete
#else
[201] Fix | Delete
#define ev_ssize_t ssize_t
[202] Fix | Delete
#endif
[203] Fix | Delete
[204] Fix | Delete
/* Note that we define ev_off_t based on the compile-time size of off_t that
[205] Fix | Delete
* we used to build Libevent, and not based on the current size of off_t.
[206] Fix | Delete
* (For example, we don't define ev_off_t to off_t.). We do this because
[207] Fix | Delete
* some systems let you build your software with different off_t sizes
[208] Fix | Delete
* at runtime, and so putting in any dependency on off_t would risk API
[209] Fix | Delete
* mismatch.
[210] Fix | Delete
*/
[211] Fix | Delete
#ifdef _WIN32
[212] Fix | Delete
#define ev_off_t ev_int64_t
[213] Fix | Delete
#elif EVENT__SIZEOF_OFF_T == 8
[214] Fix | Delete
#define ev_off_t ev_int64_t
[215] Fix | Delete
#elif EVENT__SIZEOF_OFF_T == 4
[216] Fix | Delete
#define ev_off_t ev_int32_t
[217] Fix | Delete
#elif defined(EVENT_IN_DOXYGEN_)
[218] Fix | Delete
#define ev_off_t ...
[219] Fix | Delete
#else
[220] Fix | Delete
#define ev_off_t off_t
[221] Fix | Delete
#endif
[222] Fix | Delete
/**@}*/
[223] Fix | Delete
[224] Fix | Delete
/* Limits for integer types.
[225] Fix | Delete
[226] Fix | Delete
We're making two assumptions here:
[227] Fix | Delete
- The compiler does constant folding properly.
[228] Fix | Delete
- The platform does signed arithmetic in two's complement.
[229] Fix | Delete
*/
[230] Fix | Delete
[231] Fix | Delete
/**
[232] Fix | Delete
@name Limits for integer types
[233] Fix | Delete
[234] Fix | Delete
These macros hold the largest or smallest values possible for the
[235] Fix | Delete
ev_[u]int*_t types.
[236] Fix | Delete
[237] Fix | Delete
@{
[238] Fix | Delete
*/
[239] Fix | Delete
#ifndef EVENT__HAVE_STDINT_H
[240] Fix | Delete
#define EV_UINT64_MAX ((((ev_uint64_t)0xffffffffUL) << 32) | 0xffffffffUL)
[241] Fix | Delete
#define EV_INT64_MAX ((((ev_int64_t) 0x7fffffffL) << 32) | 0xffffffffL)
[242] Fix | Delete
#define EV_INT64_MIN ((-EV_INT64_MAX) - 1)
[243] Fix | Delete
#define EV_UINT32_MAX ((ev_uint32_t)0xffffffffUL)
[244] Fix | Delete
#define EV_INT32_MAX ((ev_int32_t) 0x7fffffffL)
[245] Fix | Delete
#define EV_INT32_MIN ((-EV_INT32_MAX) - 1)
[246] Fix | Delete
#define EV_UINT16_MAX ((ev_uint16_t)0xffffUL)
[247] Fix | Delete
#define EV_INT16_MAX ((ev_int16_t) 0x7fffL)
[248] Fix | Delete
#define EV_INT16_MIN ((-EV_INT16_MAX) - 1)
[249] Fix | Delete
#define EV_UINT8_MAX 255
[250] Fix | Delete
#define EV_INT8_MAX 127
[251] Fix | Delete
#define EV_INT8_MIN ((-EV_INT8_MAX) - 1)
[252] Fix | Delete
#else
[253] Fix | Delete
#define EV_UINT64_MAX UINT64_MAX
[254] Fix | Delete
#define EV_INT64_MAX INT64_MAX
[255] Fix | Delete
#define EV_INT64_MIN INT64_MIN
[256] Fix | Delete
#define EV_UINT32_MAX UINT32_MAX
[257] Fix | Delete
#define EV_INT32_MAX INT32_MAX
[258] Fix | Delete
#define EV_INT32_MIN INT32_MIN
[259] Fix | Delete
#define EV_UINT16_MAX UINT16_MAX
[260] Fix | Delete
#define EV_INT16_MAX INT16_MAX
[261] Fix | Delete
#define EV_UINT8_MAX UINT8_MAX
[262] Fix | Delete
#define EV_INT8_MAX INT8_MAX
[263] Fix | Delete
#define EV_INT8_MIN INT8_MIN
[264] Fix | Delete
/** @} */
[265] Fix | Delete
#endif
[266] Fix | Delete
[267] Fix | Delete
[268] Fix | Delete
/**
[269] Fix | Delete
@name Limits for SIZE_T and SSIZE_T
[270] Fix | Delete
[271] Fix | Delete
@{
[272] Fix | Delete
*/
[273] Fix | Delete
#if EVENT__SIZEOF_SIZE_T == 8
[274] Fix | Delete
#define EV_SIZE_MAX EV_UINT64_MAX
[275] Fix | Delete
#define EV_SSIZE_MAX EV_INT64_MAX
[276] Fix | Delete
#elif EVENT__SIZEOF_SIZE_T == 4
[277] Fix | Delete
#define EV_SIZE_MAX EV_UINT32_MAX
[278] Fix | Delete
#define EV_SSIZE_MAX EV_INT32_MAX
[279] Fix | Delete
#elif defined(EVENT_IN_DOXYGEN_)
[280] Fix | Delete
#define EV_SIZE_MAX ...
[281] Fix | Delete
#define EV_SSIZE_MAX ...
[282] Fix | Delete
#else
[283] Fix | Delete
#error "No way to define SIZE_MAX"
[284] Fix | Delete
#endif
[285] Fix | Delete
[286] Fix | Delete
#define EV_SSIZE_MIN ((-EV_SSIZE_MAX) - 1)
[287] Fix | Delete
/**@}*/
[288] Fix | Delete
[289] Fix | Delete
#ifdef _WIN32
[290] Fix | Delete
#define ev_socklen_t int
[291] Fix | Delete
#elif defined(EVENT__socklen_t)
[292] Fix | Delete
#define ev_socklen_t EVENT__socklen_t
[293] Fix | Delete
#else
[294] Fix | Delete
#define ev_socklen_t socklen_t
[295] Fix | Delete
#endif
[296] Fix | Delete
[297] Fix | Delete
#ifdef EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY
[298] Fix | Delete
#if !defined(EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) \
[299] Fix | Delete
&& !defined(ss_family)
[300] Fix | Delete
#define ss_family __ss_family
[301] Fix | Delete
#endif
[302] Fix | Delete
#endif
[303] Fix | Delete
[304] Fix | Delete
/**
[305] Fix | Delete
* A type wide enough to hold the output of "socket()" or "accept()". On
[306] Fix | Delete
* Windows, this is an intptr_t; elsewhere, it is an int. */
[307] Fix | Delete
#ifdef _WIN32
[308] Fix | Delete
#define evutil_socket_t intptr_t
[309] Fix | Delete
#else
[310] Fix | Delete
#define evutil_socket_t int
[311] Fix | Delete
#endif
[312] Fix | Delete
[313] Fix | Delete
/**
[314] Fix | Delete
* Structure to hold information about a monotonic timer
[315] Fix | Delete
*
[316] Fix | Delete
* Use this with evutil_configure_monotonic_time() and
[317] Fix | Delete
* evutil_gettime_monotonic().
[318] Fix | Delete
*
[319] Fix | Delete
* This is an opaque structure; you can allocate one using
[320] Fix | Delete
* evutil_monotonic_timer_new().
[321] Fix | Delete
*
[322] Fix | Delete
* @see evutil_monotonic_timer_new(), evutil_monotonic_timer_free(),
[323] Fix | Delete
* evutil_configure_monotonic_time(), evutil_gettime_monotonic()
[324] Fix | Delete
*/
[325] Fix | Delete
struct evutil_monotonic_timer
[326] Fix | Delete
#ifdef EVENT_IN_DOXYGEN_
[327] Fix | Delete
{/*Empty body so that doxygen will generate documentation here.*/}
[328] Fix | Delete
#endif
[329] Fix | Delete
;
[330] Fix | Delete
[331] Fix | Delete
#define EV_MONOT_PRECISE 1
[332] Fix | Delete
#define EV_MONOT_FALLBACK 2
[333] Fix | Delete
[334] Fix | Delete
/** Format a date string using RFC 1123 format (used in HTTP).
[335] Fix | Delete
* If `tm` is NULL, current system's time will be used.
[336] Fix | Delete
* The number of characters written will be returned.
[337] Fix | Delete
* One should check if the return value is smaller than `datelen` to check if
[338] Fix | Delete
* the result is truncated or not.
[339] Fix | Delete
*/
[340] Fix | Delete
EVENT2_EXPORT_SYMBOL int
[341] Fix | Delete
evutil_date_rfc1123(char *date, const size_t datelen, const struct tm *tm);
[342] Fix | Delete
[343] Fix | Delete
/** Allocate a new struct evutil_monotonic_timer for use with the
[344] Fix | Delete
* evutil_configure_monotonic_time() and evutil_gettime_monotonic()
[345] Fix | Delete
* functions. You must configure the timer with
[346] Fix | Delete
* evutil_configure_monotonic_time() before using it.
[347] Fix | Delete
*/
[348] Fix | Delete
EVENT2_EXPORT_SYMBOL
[349] Fix | Delete
struct evutil_monotonic_timer * evutil_monotonic_timer_new(void);
[350] Fix | Delete
[351] Fix | Delete
/** Free a struct evutil_monotonic_timer that was allocated using
[352] Fix | Delete
* evutil_monotonic_timer_new().
[353] Fix | Delete
*/
[354] Fix | Delete
EVENT2_EXPORT_SYMBOL
[355] Fix | Delete
void evutil_monotonic_timer_free(struct evutil_monotonic_timer *timer);
[356] Fix | Delete
[357] Fix | Delete
/** Set up a struct evutil_monotonic_timer; flags can include
[358] Fix | Delete
* EV_MONOT_PRECISE and EV_MONOT_FALLBACK.
[359] Fix | Delete
*/
[360] Fix | Delete
EVENT2_EXPORT_SYMBOL
[361] Fix | Delete
int evutil_configure_monotonic_time(struct evutil_monotonic_timer *timer,
[362] Fix | Delete
int flags);
[363] Fix | Delete
[364] Fix | Delete
/** Query the current monotonic time from a struct evutil_monotonic_timer
[365] Fix | Delete
* previously configured with evutil_configure_monotonic_time(). Monotonic
[366] Fix | Delete
* time is guaranteed never to run in reverse, but is not necessarily epoch-
[367] Fix | Delete
* based, or relative to any other definite point. Use it to make reliable
[368] Fix | Delete
* measurements of elapsed time between events even when the system time
[369] Fix | Delete
* may be changed.
[370] Fix | Delete
*
[371] Fix | Delete
* It is not safe to use this funtion on the same timer from multiple
[372] Fix | Delete
* threads.
[373] Fix | Delete
*/
[374] Fix | Delete
EVENT2_EXPORT_SYMBOL
[375] Fix | Delete
int evutil_gettime_monotonic(struct evutil_monotonic_timer *timer,
[376] Fix | Delete
struct timeval *tp);
[377] Fix | Delete
[378] Fix | Delete
/** Create two new sockets that are connected to each other.
[379] Fix | Delete
[380] Fix | Delete
On Unix, this simply calls socketpair(). On Windows, it uses the
[381] Fix | Delete
loopback network interface on 127.0.0.1, and only
[382] Fix | Delete
AF_INET,SOCK_STREAM are supported.
[383] Fix | Delete
[384] Fix | Delete
(This may fail on some Windows hosts where firewall software has cleverly
[385] Fix | Delete
decided to keep 127.0.0.1 from talking to itself.)
[386] Fix | Delete
[387] Fix | Delete
Parameters and return values are as for socketpair()
[388] Fix | Delete
*/
[389] Fix | Delete
EVENT2_EXPORT_SYMBOL
[390] Fix | Delete
int evutil_socketpair(int d, int type, int protocol, evutil_socket_t sv[2]);
[391] Fix | Delete
/** Do platform-specific operations as needed to make a socket nonblocking.
[392] Fix | Delete
[393] Fix | Delete
@param sock The socket to make nonblocking
[394] Fix | Delete
@return 0 on success, -1 on failure
[395] Fix | Delete
*/
[396] Fix | Delete
EVENT2_EXPORT_SYMBOL
[397] Fix | Delete
int evutil_make_socket_nonblocking(evutil_socket_t sock);
[398] Fix | Delete
[399] Fix | Delete
/** Do platform-specific operations to make a listener socket reusable.
[400] Fix | Delete
[401] Fix | Delete
Specifically, we want to make sure that another program will be able
[402] Fix | Delete
to bind this address right after we've closed the listener.
[403] Fix | Delete
[404] Fix | Delete
This differs from Windows's interpretation of "reusable", which
[405] Fix | Delete
allows multiple listeners to bind the same address at the same time.
[406] Fix | Delete
[407] Fix | Delete
@param sock The socket to make reusable
[408] Fix | Delete
@return 0 on success, -1 on failure
[409] Fix | Delete
*/
[410] Fix | Delete
EVENT2_EXPORT_SYMBOL
[411] Fix | Delete
int evutil_make_listen_socket_reuseable(evutil_socket_t sock);
[412] Fix | Delete
[413] Fix | Delete
/** Do platform-specific operations to make a listener port reusable.
[414] Fix | Delete
[415] Fix | Delete
Specifically, we want to make sure that multiple programs which also
[416] Fix | Delete
set the same socket option will be able to bind, listen at the same time.
[417] Fix | Delete
[418] Fix | Delete
This is a feature available only to Linux 3.9+
[419] Fix | Delete
[420] Fix | Delete
@param sock The socket to make reusable
[421] Fix | Delete
@return 0 on success, -1 on failure
[422] Fix | Delete
*/
[423] Fix | Delete
EVENT2_EXPORT_SYMBOL
[424] Fix | Delete
int evutil_make_listen_socket_reuseable_port(evutil_socket_t sock);
[425] Fix | Delete
[426] Fix | Delete
/** Do platform-specific operations as needed to close a socket upon a
[427] Fix | Delete
successful execution of one of the exec*() functions.
[428] Fix | Delete
[429] Fix | Delete
@param sock The socket to be closed
[430] Fix | Delete
@return 0 on success, -1 on failure
[431] Fix | Delete
*/
[432] Fix | Delete
EVENT2_EXPORT_SYMBOL
[433] Fix | Delete
int evutil_make_socket_closeonexec(evutil_socket_t sock);
[434] Fix | Delete
[435] Fix | Delete
/** Do the platform-specific call needed to close a socket returned from
[436] Fix | Delete
socket() or accept().
[437] Fix | Delete
[438] Fix | Delete
@param sock The socket to be closed
[439] Fix | Delete
@return 0 on success, -1 on failure
[440] Fix | Delete
*/
[441] Fix | Delete
EVENT2_EXPORT_SYMBOL
[442] Fix | Delete
int evutil_closesocket(evutil_socket_t sock);
[443] Fix | Delete
#define EVUTIL_CLOSESOCKET(s) evutil_closesocket(s)
[444] Fix | Delete
[445] Fix | Delete
/** Do platform-specific operations, if possible, to make a tcp listener
[446] Fix | Delete
* socket defer accept()s until there is data to read.
[447] Fix | Delete
*
[448] Fix | Delete
* Not all platforms support this. You don't want to do this for every
[449] Fix | Delete
* listener socket: only the ones that implement a protocol where the
[450] Fix | Delete
* client transmits before the server needs to respond.
[451] Fix | Delete
*
[452] Fix | Delete
* @param sock The listening socket to to make deferred
[453] Fix | Delete
* @return 0 on success (whether the operation is supported or not),
[454] Fix | Delete
* -1 on failure
[455] Fix | Delete
*/
[456] Fix | Delete
EVENT2_EXPORT_SYMBOL
[457] Fix | Delete
int evutil_make_tcp_listen_socket_deferred(evutil_socket_t sock);
[458] Fix | Delete
[459] Fix | Delete
#ifdef _WIN32
[460] Fix | Delete
/** Return the most recent socket error. Not idempotent on all platforms. */
[461] Fix | Delete
#define EVUTIL_SOCKET_ERROR() WSAGetLastError()
[462] Fix | Delete
/** Replace the most recent socket error with errcode */
[463] Fix | Delete
#define EVUTIL_SET_SOCKET_ERROR(errcode) \
[464] Fix | Delete
do { WSASetLastError(errcode); } while (0)
[465] Fix | Delete
/** Return the most recent socket error to occur on sock. */
[466] Fix | Delete
EVENT2_EXPORT_SYMBOL
[467] Fix | Delete
int evutil_socket_geterror(evutil_socket_t sock);
[468] Fix | Delete
/** Convert a socket error to a string. */
[469] Fix | Delete
EVENT2_EXPORT_SYMBOL
[470] Fix | Delete
const char *evutil_socket_error_to_string(int errcode);
[471] Fix | Delete
#elif defined(EVENT_IN_DOXYGEN_)
[472] Fix | Delete
/**
[473] Fix | Delete
@name Socket error functions
[474] Fix | Delete
[475] Fix | Delete
These functions are needed for making programs compatible between
[476] Fix | Delete
Windows and Unix-like platforms.
[477] Fix | Delete
[478] Fix | Delete
You see, Winsock handles socket errors differently from the rest of
[479] Fix | Delete
the world. Elsewhere, a socket error is like any other error and is
[480] Fix | Delete
stored in errno. But winsock functions require you to retrieve the
[481] Fix | Delete
error with a special function, and don't let you use strerror for
[482] Fix | Delete
the error codes. And handling EWOULDBLOCK is ... different.
[483] Fix | Delete
[484] Fix | Delete
@{
[485] Fix | Delete
*/
[486] Fix | Delete
/** Return the most recent socket error. Not idempotent on all platforms. */
[487] Fix | Delete
#define EVUTIL_SOCKET_ERROR() ...
[488] Fix | Delete
/** Replace the most recent socket error with errcode */
[489] Fix | Delete
#define EVUTIL_SET_SOCKET_ERROR(errcode) ...
[490] Fix | Delete
/** Return the most recent socket error to occur on sock. */
[491] Fix | Delete
#define evutil_socket_geterror(sock) ...
[492] Fix | Delete
/** Convert a socket error to a string. */
[493] Fix | Delete
#define evutil_socket_error_to_string(errcode) ...
[494] Fix | Delete
/**@}*/
[495] Fix | Delete
#else
[496] Fix | Delete
#define EVUTIL_SOCKET_ERROR() (errno)
[497] Fix | Delete
#define EVUTIL_SET_SOCKET_ERROR(errcode) \
[498] Fix | Delete
do { errno = (errcode); } while (0)
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function