add support for connect with socket buffer size

This commit is contained in:
mculover666
2021-04-16 16:50:39 +08:00
parent 3fc92b3c91
commit 6084de9e41
6 changed files with 162 additions and 42 deletions

View File

@@ -43,6 +43,14 @@ int tos_sal_module_connect(const char *ip, const char *port, sal_proto_t proto)
return -1;
}
int tos_sal_module_connect_with_size(const char *ip, const char *port, sal_proto_t proto, size_t socket_buffer_size)
{
if (g_sal_module && g_sal_module->connect_with_size) {
return g_sal_module->connect_with_size(ip, port, proto, socket_buffer_size);
}
return -1;
}
int tos_sal_module_send(int sock, const void *buf, size_t len)
{
if (g_sal_module && g_sal_module->send) {

View File

@@ -37,6 +37,8 @@ typedef struct sal_module_st {
int (*connect)(const char *ip, const char *port, sal_proto_t proto);
int (*connect_with_size)(const char *ip, const char *port, sal_proto_t proto, size_t socket_buffer_size);
int (*send)(int sock, const void *buf, size_t len);
int (*recv_timeout)(int sock, void *buf, size_t len, uint32_t timeout);
@@ -109,6 +111,20 @@ int tos_sal_module_parse_domain(const char *host_name, char *host_ip, size_t hos
*/
int tos_sal_module_connect(const char *ip, const char *port, sal_proto_t proto);
/**
* @brief Connect to remote host with socket buffer size.
*
* @attention None
*
* @param[in] ip ip address of the remote host
* @param[in] port port number of the remote host
* @param[in] proto protocol of the connection(TCP/UDP)
* @param[in] socket_buffer_size the buffer size of the socket
*
* @return socket id if succuss, -1 if failed.
*/
int tos_sal_module_connect_with_size(const char *ip, const char *port, sal_proto_t proto, size_t socket_buffer_size);
/**
* @brief Send data to the remote host(TCP).
*