2020-03-26 11:56:57 +08:00
|
|
|
#ifndef __WIN_PATCH_INCLUDE_H__
|
|
|
|
#define __WIN_PATCH_INCLUDE_H__
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
# include <winsock2.h>
|
|
|
|
# define HAVE_NO_GETOPT
|
|
|
|
# define snprintf _snprintf
|
|
|
|
extern int optind;
|
|
|
|
extern char *optarg;
|
2022-10-23 18:08:20 +08:00
|
|
|
int getopt(int argc, char *argv[], const char *opts);
|
2020-03-26 11:56:57 +08:00
|
|
|
#else
|
|
|
|
# define SOCKET int
|
|
|
|
# define INVALID_SOCKET -1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void socket_init(void);
|
|
|
|
void socket_end(void);
|
|
|
|
void socket_close(SOCKET fd);
|
|
|
|
SOCKET socket_listen(const char *ip, int port);
|
|
|
|
SOCKET socket_accept(SOCKET fd);
|
|
|
|
SOCKET socket_connect(const char *ip, int port);
|
2022-10-12 17:55:50 +08:00
|
|
|
int set_non_blocking(SOCKET fd, int on);
|
|
|
|
int socket_is_non_blocking(SOCKET fd);
|
2020-03-26 11:56:57 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|