acl/lib_acl/include/net/acl_connect.h

91 lines
2.9 KiB
C
Raw Normal View History

2014-11-19 00:25:21 +08:00
#ifndef ACL_CONNECT_INCLUDE_H
#define ACL_CONNECT_INCLUDE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "stdlib/acl_define.h"
#ifdef ACL_UNIX
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#endif
/* in acl_sane_connect.c */
/**
* Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param sock {ACL_SOCKET} <EFBFBD>׽<EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD>UNIXƽ̨<EFBFBD>»<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @param sa {const struct sockaddr*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
* @param len {socklen_t} sa <EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {int} 0: <EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD>; -1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
*/
ACL_API int acl_sane_connect(ACL_SOCKET sock, const struct sockaddr * sa,
socklen_t len);
/* in acl_timed_connect.c */
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fd {ACL_SOCKET} <EFBFBD>׽<EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD>UNIXƽ̨<EFBFBD>»<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @param sa {const struct sockaddr*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
* @param len {socklen_t} sa <EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param timeout {int} <EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱʱ<EFBFBD><EFBFBD>
* @return {int} 0: <EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD>; -1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
*/
ACL_API int acl_timed_connect(ACL_SOCKET fd, const struct sockaddr * sa,
socklen_t len, int timeout);
/* in acl_inet_connect.c */
/**
* Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
2017-04-07 20:13:08 +08:00
* @param addr {const char*} Զ<EFBFBD>̷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>192.168.0.1:80, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* Ҫ<EFBFBD>󶨱<EFBFBD><EFBFBD>صĵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽΪ: {local_ip}@{remote_addr},
* <EFBFBD><EFBFBD>: 60.28.250.199@www.sina.com:80
* @param blocking {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ, ACL_BLOCKING <EFBFBD><EFBFBD> ACL_NON_BLOCKING
* @param timeout {int} <EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> blocking Ϊ ACL_NON_BLOCKING <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
* @return {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_SOCKET_INVALID <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
*/
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
/**
* Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
* @param addr {const char*} Զ<EFBFBD>̷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>192.168.0.1:80<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>
2017-04-07 20:13:08 +08:00
* local_ip@remote_ip:remote_port<EFBFBD><EFBFBD><EFBFBD>192.168.1.1@211.150.111.12:80
* @param blocking {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ, ACL_BLOCKING <EFBFBD><EFBFBD> ACL_NON_BLOCKING
* @param timeout {int} <EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> blocking Ϊ ACL_NON_BLOCKING <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
* @param h_error {int*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>ʱ<EFBFBD>ʧ<EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_SOCKET_INVALID <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
*/
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 */
/**
* <EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param addr {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>ȫ·<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>: /tmp/test.sock
2017-04-07 20:13:08 +08:00
* @param blocking {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ, ACL_BLOCKING <EFBFBD><EFBFBD> ACL_NON_BLOCKING
* @param timeout {int} <EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> blocking Ϊ ACL_NON_BLOCKING <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
* @return {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_SOCKET_INVALID <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
*/
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
#ifdef __cplusplus
}
#endif
#endif