summaryrefslogtreecommitdiff
path: root/toxcore/TCP_client.c
diff options
context:
space:
mode:
authorDiadlo <polsha3@gmail.com>2017-01-03 19:26:15 +0300
committerDiadlo <polsha3@gmail.com>2017-01-26 23:11:15 +0300
commitf00006cf1d966270b6142519ad7d8487fb5eff5a (patch)
treeb62ef423ad71abfe2f6a53ca0fede7510c07fdd5 /toxcore/TCP_client.c
parent287a29b8269eabfb33f07b9e0388a68be7ad2ba0 (diff)
Add platform-independent Socket and IP implementation
Diffstat (limited to 'toxcore/TCP_client.c')
-rw-r--r--toxcore/TCP_client.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c
index e6d8e3b4..3d65415e 100644
--- a/toxcore/TCP_client.c
+++ b/toxcore/TCP_client.c
@@ -36,7 +36,7 @@
36/* return 1 on success 36/* return 1 on success
37 * return 0 on failure 37 * return 0 on failure
38 */ 38 */
39static int connect_sock_to(sock_t sock, IP_Port ip_port, TCP_Proxy_Info *proxy_info) 39static int connect_sock_to(Socket sock, IP_Port ip_port, TCP_Proxy_Info *proxy_info)
40{ 40{
41 if (proxy_info->proxy_type != TCP_PROXY_NONE) { 41 if (proxy_info->proxy_type != TCP_PROXY_NONE) {
42 ip_port = proxy_info->ip_port; 42 ip_port = proxy_info->ip_port;
@@ -51,14 +51,14 @@ static int connect_sock_to(sock_t sock, IP_Port ip_port, TCP_Proxy_Info *proxy_i
51 51
52 addrsize = sizeof(struct sockaddr_in); 52 addrsize = sizeof(struct sockaddr_in);
53 addr4->sin_family = AF_INET; 53 addr4->sin_family = AF_INET;
54 addr4->sin_addr = ip_port.ip.ip4.in_addr; 54 fill_addr4(ip_port.ip.ip4, &addr4->sin_addr);
55 addr4->sin_port = ip_port.port; 55 addr4->sin_port = ip_port.port;
56 } else if (ip_port.ip.family == AF_INET6) { 56 } else if (ip_port.ip.family == AF_INET6) {
57 struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&addr; 57 struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&addr;
58 58
59 addrsize = sizeof(struct sockaddr_in6); 59 addrsize = sizeof(struct sockaddr_in6);
60 addr6->sin6_family = AF_INET6; 60 addr6->sin6_family = AF_INET6;
61 addr6->sin6_addr = ip_port.ip.ip6.in6_addr; 61 fill_addr6(ip_port.ip.ip6, &addr6->sin6_addr);
62 addr6->sin6_port = ip_port.port; 62 addr6->sin6_port = ip_port.port;
63 } else { 63 } else {
64 return 0; 64 return 0;
@@ -653,7 +653,7 @@ TCP_Client_Connection *new_TCP_connection(IP_Port ip_port, const uint8_t *public
653 family = proxy_info->ip_port.ip.family; 653 family = proxy_info->ip_port.ip.family;
654 } 654 }
655 655
656 sock_t sock = socket(family, SOCK_STREAM, IPPROTO_TCP); 656 Socket sock = socket(family, SOCK_STREAM, IPPROTO_TCP);
657 657
658 if (!sock_valid(sock)) { 658 if (!sock_valid(sock)) {
659 return NULL; 659 return NULL;