summaryrefslogtreecommitdiffstats
path: root/tinyNET/test/test_sockets.h
blob: 3edd1bd8311a745677d12bcf8de61506363a004c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Copyright (C) 2014 Mamadou DIOP.
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
#ifndef TNET_TEST_SOCKETS_H
#define TNET_TEST_SOCKETS_H

void test_sockets()
{
	int test;
	tnet_socket_tcp_t * tcp_socket;
	tnet_socket_type_t type = tnet_socket_type_udp_ipv4;
	struct sockaddr_storage to;
	
	TNET_SOCKET_TYPE_SET_IPV4(type);
	TNET_SOCKET_TYPE_SET_IPV6(type);
	TNET_SOCKET_TYPE_SET_IPV4Only(type);
	TNET_SOCKET_TYPE_SET_IPV6Only(type);
	TNET_SOCKET_TYPE_SET_IPV6Only(type);
	TNET_SOCKET_TYPE_SET_IPV4(type);
	TNET_SOCKET_TYPE_SET_IPV6(type);

	TNET_SOCKET_TYPE_SET_TLS(type);
	TNET_SOCKET_TYPE_SET_UDP(type);
	TNET_SOCKET_TYPE_SET_SCTP(type);
	TNET_SOCKET_TYPE_SET_TCP(type);
	
	tcp_socket = tnet_socket_create(TNET_SOCKET_HOST_ANY, TNET_SOCKET_PORT_ANY, type);

	if(!TNET_SOCKET_IS_VALID(tcp_socket))
	{
		TSK_OBJECT_SAFE_FREE(tcp_socket);
		return;
	}

	//if(!(test = tnet_sockaddr_init("www.google.com", 80, type, &to))){
	//	test = tnet_sockfd_connetto(tcp_socket->fd, (const struct sockaddr_storage *)&to);
	//}

	if(!(test = tnet_sockaddr_init("ipv6.google.com", 80, type, &to))){
		test = tnet_sockfd_connectto(tcp_socket->fd, (const struct sockaddr_storage *)&to);
	}

	TSK_OBJECT_SAFE_FREE(tcp_socket);
}

#endif /* TNET_TEST_SOCKETS_H */
OpenPOWER on IntegriCloud