TCP and UDP sockets localEndpoint
This commit is contained in:
@@ -47,8 +47,12 @@ typedef struct {
|
||||
void* tcp_client_connect_async(void* _data){
|
||||
tcp_client_connect_async_data* data = _data;
|
||||
tryLast(knSocketTCP_connect(data->socket_client, data->serverEnd), _m8531,;);
|
||||
|
||||
kprintf_safe("\e[92mclient socket connected to server\n");
|
||||
|
||||
char* adrstr = knIPV4Endpoint_toString(&data->socket_client->localEndpoint);
|
||||
kprintf("\e[92mclient socket was implicitely bound to %s\n\e[94m", adrstr);
|
||||
free(adrstr);
|
||||
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
@@ -63,7 +67,8 @@ static void test_tcp(){
|
||||
socket_server=m_socketS.value.VoidPtr;
|
||||
kprintf("\e[92mTCP server socket created\n");
|
||||
|
||||
tryLast(knSocketTCP_bindAndListen(socket_server, serverEnd), _m81775, ;)
|
||||
tryLast(knSocketTCP_bind(socket_server, serverEnd), _m81775, ;)
|
||||
tryLast(knSocketTCP_listen(socket_server), _m88775, ;)
|
||||
kprintf("\e[92mserver socket is listening\n");
|
||||
}
|
||||
// client
|
||||
@@ -161,6 +166,10 @@ void test_udp(){
|
||||
const char client_msg[] = "ping";
|
||||
tryLast(knSocketUDP_sendTo(socket_client, client_msg, sizeof(client_msg), serverEnd), _mu75q2, ;);
|
||||
kprintf("\e[92mmessage sent to server\n\e[94m");
|
||||
|
||||
char* adrstr = knIPV4Endpoint_toString(&socket_client->localEndpoint);
|
||||
kprintf("\e[92mclient socket was implicitely bound to %s\n\e[94m", adrstr);
|
||||
free(adrstr);
|
||||
}
|
||||
// server
|
||||
{
|
||||
|
||||
@@ -24,19 +24,19 @@ void test_network();
|
||||
inline void test_all(){
|
||||
kprintf("\e[97mkerep tests are starting!\n");
|
||||
optime(__func__, 1,
|
||||
test_cptr();
|
||||
test_type_system();
|
||||
test_string();
|
||||
test_safethrow();
|
||||
test_searchtree();
|
||||
test_autoarr();
|
||||
test_autoarrVsVector();
|
||||
test_rng_algorithms();
|
||||
test_kprint_colors();
|
||||
test_kprint();
|
||||
test_hash_functions();
|
||||
test_hashtable();
|
||||
test_dtsod();
|
||||
// test_cptr();
|
||||
// test_type_system();
|
||||
// test_string();
|
||||
// test_safethrow();
|
||||
// test_searchtree();
|
||||
// test_autoarr();
|
||||
// test_autoarrVsVector();
|
||||
// test_rng_algorithms();
|
||||
// test_kprint_colors();
|
||||
// test_kprint();
|
||||
// test_hash_functions();
|
||||
// test_hashtable();
|
||||
// test_dtsod();
|
||||
test_network();
|
||||
kprintf("\e[96m--------------------------------------\e[0m\n");
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user