提交 082a322f 编写于 作者: Y YuQing

change port type to uint16_t

上级 55fc4013
......@@ -36,7 +36,7 @@ extern "C" {
typedef struct
{
int sock;
short port;
uint16_t port;
short socket_domain; //socket domain, AF_INET, AF_INET6 or AF_UNSPEC for auto dedect
bool validate_flag; //for connection pool
char ip_addr[INET6_ADDRSTRLEN];
......@@ -306,7 +306,7 @@ static inline void conn_pool_set_server_info(ConnectionInfo *pServerInfo,
}
static inline int conn_pool_compare_ip_and_port(const char *ip1,
const short port1, const char *ip2, const short port2)
const int port1, const char *ip2, const int port2)
{
int result;
if ((result=strcmp(ip1, ip2)) != 0) {
......
......@@ -471,7 +471,7 @@ int tcpsenddata_nb(int sock, void* data, const int size, const int timeout)
return 0;
}
int setsockaddrbyip(const char *ip, const short port, sockaddr_convert_t *convert)
int setsockaddrbyip(const char *ip, const uint16_t port, sockaddr_convert_t *convert)
{
int af;
void *dest;
......@@ -505,7 +505,7 @@ int setsockaddrbyip(const char *ip, const short port, sockaddr_convert_t *conver
return 0;
}
int connectserverbyip(int sock, const char *server_ip, const short server_port)
int connectserverbyip(int sock, const char *server_ip, const uint16_t server_port)
{
int result;
sockaddr_convert_t convert;
......@@ -524,7 +524,7 @@ int connectserverbyip(int sock, const char *server_ip, const short server_port)
}
int connectserverbyip_nb_ex(int sock, const char *server_ip, \
const short server_port, const int timeout, \
const uint16_t server_port, const int timeout, \
const bool auto_detect)
{
int result;
......@@ -636,7 +636,7 @@ int connectserverbyip_nb_ex(int sock, const char *server_ip, \
}
int asyncconnectserverbyip(int sock, const char *server_ip,
const short server_port)
const uint16_t server_port)
{
int result;
sockaddr_convert_t convert;
......@@ -701,7 +701,7 @@ int socketCreateEx2(int af, const char *server_ip,
}
int socketClientEx2(int af, const char *server_ip,
const short server_port, const int timeout,
const uint16_t server_port, const int timeout,
const int flags, const char *bind_ipaddr, int *err_no)
{
int sock;
......
......@@ -171,7 +171,7 @@ int tcpsenddata_nb(int sock, void* data, const int size, const int timeout);
* server_port: port of the server
* return: error no, 0 success, != 0 fail
*/
int connectserverbyip(int sock, const char *server_ip, const short server_port);
int connectserverbyip(int sock, const char *server_ip, const uint16_t server_port);
/** connect to server by non-block mode
* parameters:
......@@ -183,7 +183,7 @@ int connectserverbyip(int sock, const char *server_ip, const short server_port);
* return: error no, 0 success, != 0 fail
*/
int connectserverbyip_nb_ex(int sock, const char *server_ip, \
const short server_port, const int timeout, \
const uint16_t server_port, const int timeout, \
const bool auto_detect);
/** connect to server by non-block mode, the socket must be set to non-block
......@@ -217,7 +217,7 @@ int connectserverbyip_nb_ex(int sock, const char *server_ip, \
* return: error no, 0 or EINPROGRESS for success, others for fail
*/
int asyncconnectserverbyip(int sock, const char *server_ip,
const short server_port);
const uint16_t server_port);
/** accept client connect request
* parameters:
......@@ -414,7 +414,7 @@ static inline int socketCreateExAuto(const char *server_ip,
* return: >= 0 server socket, < 0 fail
*/
int socketClientEx2(int af, const char *server_ip,
const short server_port, const int timeout,
const uint16_t server_port, const int timeout,
const int flags, const char *bind_ipaddr, int *err_no);
/** connect to server
......@@ -428,7 +428,7 @@ int socketClientEx2(int af, const char *server_ip,
* return: >= 0 server socket, < 0 fail
*/
static inline int socketClientExAuto(const char *server_ip,
const short server_port, const int timeout,
const uint16_t server_port, const int timeout,
const int flags, const char *bind_ipaddr, int *err_no)
{
return socketClientEx2(AF_UNSPEC, server_ip, server_port,
......@@ -446,7 +446,7 @@ static inline int socketClientExAuto(const char *server_ip,
* return: >= 0 server socket, < 0 fail
*/
static inline int socketClientAuto(const char *server_ip,
const short server_port, const int timeout,
const uint16_t server_port, const int timeout,
const int flags, int *err_no)
{
return socketClientEx2(AF_UNSPEC, server_ip, server_port,
......@@ -464,7 +464,7 @@ static inline int socketClientAuto(const char *server_ip,
* return: >= 0 server socket, < 0 fail
*/
static inline int socketClient2(int af, const char *server_ip,
const short server_port, const int timeout,
const uint16_t server_port, const int timeout,
const int flags, int *err_no)
{
return socketClientEx2(af, server_ip, server_port,
......@@ -481,7 +481,7 @@ static inline int socketClient2(int af, const char *server_ip,
* return: >= 0 server socket, < 0 fail
*/
static inline int socketClient(const char *server_ip,
const short server_port, const int timeout,
const uint16_t server_port, const int timeout,
const int flags, int *err_no)
{
return socketClient2(AF_INET, server_ip, server_port,
......@@ -498,7 +498,7 @@ static inline int socketClient(const char *server_ip,
* return: >= 0 server socket, < 0 fail
*/
static inline int socketClientIPv6(const char *server_ip,
const short server_port, const int timeout,
const uint16_t server_port, const int timeout,
const int flags, int *err_no)
{
return socketClient2(AF_INET6, server_ip, server_port,
......@@ -611,7 +611,7 @@ int getifconfigs(FastIFConfig *if_configs, const int max_count, int *count);
* convert: the convert struct for IPv4 and IPv6 compatibility
* return: error no, 0 success, != 0 fail
*/
int setsockaddrbyip(const char *ip, const short port, sockaddr_convert_t *convert);
int setsockaddrbyip(const char *ip, const uint16_t port, sockaddr_convert_t *convert);
static inline bool is_ipv6_addr(const char *ip)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册