acl/lib_acl/include/net/acl_connect.h

100 lines
3.5 KiB
C
Raw Normal View History

#ifndef ACL_CONNECT_INCLUDE_H
2014-11-19 00:25:21 +08:00
#define ACL_CONNECT_INCLUDE_H
#ifdef __cplusplus
extern "C" {
#endif
2017-06-02 14:47:24 +08:00
#include "../stdlib/acl_define.h"
2014-11-19 00:25:21 +08:00
#ifdef ACL_UNIX
#include <sys/types.h>
2014-11-19 00:25:21 +08:00
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#endif
/* in acl_sane_connect.c */
/**
*
* @param sock {ACL_SOCKET} UNIX平台下还可以是域套接字
* @param sa {const struct sockaddr*}
* @param len {socklen_t} sa
* @return {int} 0: ; -1:
2014-11-19 00:25:21 +08:00
*/
ACL_API int acl_sane_connect(ACL_SOCKET sock, const struct sockaddr * sa,
socklen_t len);
/* in acl_timed_connect.c */
/**
*
* @param fd {ACL_SOCKET} UNIX平台下还可以是域套接字
* @param sa {const struct sockaddr*}
* @param len {socklen_t} sa
* @param timeout {int}
* @return {int} 0: ; -1:
2014-11-19 00:25:21 +08:00
*/
ACL_API int acl_timed_connect(ACL_SOCKET fd, const struct sockaddr * sa,
socklen_t len, int timeout);
/* in acl_inet_connect.c */
/**
*
* @param addr {const char*} 192.168.0.1:80,
* : {local_ip}@{remote_addr},
* : 60.28.250.199@www.sina.com:80
* @param blocking {int} , ACL_BLOCKING ACL_NON_BLOCKING
* @param timeout {int} blocking ACL_NON_BLOCKING
* @return {ACL_SOCKET} ACL_SOCKET_INVALID
2014-11-19 00:25:21 +08:00
*/
2017-04-07 20:13:08 +08:00
ACL_API ACL_SOCKET acl_inet_connect(const char *addr, int blocking, int timeout);
2014-11-19 00:25:21 +08:00
/**
*
* @param addr {const char*} 192.168.0.1:80
*
* local_ip@remote_ip:remote_port192.168.1.1@211.150.111.12:80
* @param blocking {int} , ACL_BLOCKING ACL_NON_BLOCKING
* @param timeout {int} blocking ACL_NON_BLOCKING
* @param h_error {int*}
* @return {ACL_SOCKET} ACL_SOCKET_INVALID
2014-11-19 00:25:21 +08:00
*/
2017-04-07 20:13:08 +08:00
ACL_API ACL_SOCKET acl_inet_connect_ex(const char *addr, int blocking,
2014-11-19 00:25:21 +08:00
int timeout, int *h_error);
#ifdef ACL_UNIX
/* in acl_unix_connect.c */
/**
*
* @param addr {const char*} , : /tmp/test.sock
* @param blocking {int} , ACL_BLOCKING ACL_NON_BLOCKING
* @param timeout {int} blocking ACL_NON_BLOCKING
* @return {ACL_SOCKET} ACL_SOCKET_INVALID
2014-11-19 00:25:21 +08:00
*/
2017-04-07 20:13:08 +08:00
ACL_API ACL_SOCKET acl_unix_connect(const char *addr, int blocking, int timeout);
2014-11-19 00:25:21 +08:00
/* in acl_stream_connect.c */
#ifdef SUNOS5
2017-04-07 20:13:08 +08:00
ACL_API int acl_stream_connect(const char *path, int blocking, int timeout);
2014-11-19 00:25:21 +08:00
#endif
#endif
#if defined(_WIN32) || defined(_WIN64)
typedef int (WINAPI *acl_connect_fn)(SOCKET, const struct sockaddr*, socklen_t);
#else
typedef int (*acl_connect_fn)(int, const struct sockaddr*, socklen_t);
#endif
ACL_API void acl_set_connect(acl_connect_fn fn);
2014-11-19 00:25:21 +08:00
#ifdef __cplusplus
}
#endif
#endif