Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
86747d9
Reorder header
dosshell May 5, 2026
dfac33a
Add tcs_strerror function
dosshell May 5, 2026
a42f4aa
Reorder parameters for tcs_receive
dosshell May 6, 2026
568c500
Change SO and SOL types from int to int32_t
dosshell May 6, 2026
9ab5040
Use out prefix for out parameters
dosshell May 6, 2026
f087370
Rename socket_ctx parameters to socket
dosshell May 6, 2026
305f977
Use doxygen verbatim for tcs_address_parse examples
dosshell May 6, 2026
2dc10d0
Fix tcs_socket_tcp_str doc to mention resolve, not parse
dosshell May 6, 2026
79f5e4a
Remove misleading IPv6 byte order comment
dosshell May 6, 2026
393b1c8
Fix tcs_close documented return values
dosshell May 6, 2026
f4f6320
Clarify tcs_connect timeout behavior
dosshell May 6, 2026
1b05615
Fix tcs_accept port inheritance documentation
dosshell May 6, 2026
3dc1168
Use TcsInterfaceId for tcs_address_list filter
dosshell May 6, 2026
6e0907a
Document send/receive flag values
dosshell May 6, 2026
64a87bf
Use size and length naming
dosshell May 6, 2026
b7d473d
Rename IP4/IP6 to IPV4/IPV6
dosshell May 7, 2026
ee348c7
Rename TcsSockType to TcsSocketType and TCS_SOCK_* to TCS_SOCKET_*
dosshell May 7, 2026
0dafb72
Use TcsAddressIpv4 typedef
dosshell May 7, 2026
d50e11c
Move license text to common
dosshell May 7, 2026
19d8900
Use out prefix for more parameters
dosshell May 7, 2026
91843a7
Rename tcs_lib_free to tcs_lib_cleanup
dosshell May 7, 2026
f4a665b
Add in,out,inoout specifiers to doxygen
dosshell May 7, 2026
4a53a31
Rename TCS_ADDRESS_*_IPV4 to TCS_ADDRESS_IPV4_*
dosshell May 7, 2026
f4ffdc0
Clang format
dosshell May 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main(int argc, const char* argv[])
tcs_lib_init();

TcsSocket client_socket = TCS_SOCKET_INVALID;
tcs_socket(&client_socket, TCS_FAMILY_IP4, TCS_SOCK_STREAM, TCS_PROTOCOL_IP_TCP);
tcs_socket(&client_socket, TCS_FAMILY_IPV4, TCS_SOCKET_STREAM, TCS_PROTOCOL_IP_TCP);
tcs_connect_str(client_socket, "example.com", 80);

uint8_t send_buffer[] =
Expand All @@ -37,7 +37,7 @@ int main(int argc, const char* argv[])
tcs_shutdown(client_socket, TCS_SHUTDOWN_BOTH);
tcs_close(&client_socket);

tcs_lib_free();
tcs_lib_cleanup();
}
```

Expand Down
8 changes: 4 additions & 4 deletions examples/tcp_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ int main(void)

uint8_t recv_buffer[1024];
size_t recv_size = sizeof(recv_buffer) - 1;
size_t bytes_received = 0;
if (tcs_receive(client_socket, recv_buffer, recv_size, TCS_FLAG_NONE, &bytes_received) != TCS_SUCCESS)
size_t received_size = 0;
if (tcs_receive(client_socket, recv_buffer, recv_size, TCS_FLAG_NONE, &received_size) != TCS_SUCCESS)
return show_error("Could not receive data");

// Makes sure it is a NULL terminated string, this is why we only accept 1023 bytes in receive
recv_buffer[bytes_received] = '\0';
recv_buffer[received_size] = '\0';
printf("received: %s\n", recv_buffer);

if (tcs_shutdown(client_socket, TCS_SHUTDOWN_BOTH) != TCS_SUCCESS)
Expand All @@ -64,6 +64,6 @@ int main(void)
if (tcs_close(&client_socket) != TCS_SUCCESS)
return show_error("Could not close the socket");

if (tcs_lib_free() != TCS_SUCCESS)
if (tcs_lib_cleanup() != TCS_SUCCESS)
return show_error("Could not free tinycsocket");
}
8 changes: 4 additions & 4 deletions examples/tcp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ int main(void)

uint8_t recv_buffer[1024];
size_t recv_size = sizeof(recv_buffer) - 1;
size_t bytes_received = 0;
if (tcs_receive(child_socket, recv_buffer, recv_size, TCS_FLAG_NONE, &bytes_received) != TCS_SUCCESS)
size_t received_size = 0;
if (tcs_receive(child_socket, recv_buffer, recv_size, TCS_FLAG_NONE, &received_size) != TCS_SUCCESS)
return show_error("Could not receive data from client");

recv_buffer[bytes_received] = '\0';
recv_buffer[received_size] = '\0';
printf("received: %s\n", recv_buffer);

char msg[] = "I hear you loud and clear\n";
Expand All @@ -71,6 +71,6 @@ int main(void)
if (tcs_close(&child_socket) != TCS_SUCCESS)
return show_error("Could not close socket");

if (tcs_lib_free() != TCS_SUCCESS)
if (tcs_lib_cleanup() != TCS_SUCCESS)
return show_error("Could not free tinycsocket");
}
8 changes: 4 additions & 4 deletions examples/udp_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ int main(void)

uint8_t recv_buffer[1024];
size_t recv_size = sizeof(recv_buffer) - 1;
size_t bytes_received = 0;
if (tcs_receive(socket, recv_buffer, recv_size, TCS_FLAG_NONE, &bytes_received) != TCS_SUCCESS)
size_t received_size = 0;
if (tcs_receive(socket, recv_buffer, recv_size, TCS_FLAG_NONE, &received_size) != TCS_SUCCESS)
return show_error("Could not receive data");

// Makes sure it is a NULL terminated string, this is why we only accept 1023 bytes in receive
recv_buffer[bytes_received] = '\0';
recv_buffer[received_size] = '\0';
printf("received: %s\n", recv_buffer);

if (tcs_close(&socket) != TCS_SUCCESS)
return show_error("Could not close socket");

if (tcs_lib_free() != TCS_SUCCESS)
if (tcs_lib_cleanup() != TCS_SUCCESS)
return show_error("Could not free tinycsocket");
}
9 changes: 4 additions & 5 deletions examples/udp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ int main(void)
struct TcsAddress remote_address = {0};
uint8_t recv_buffer[1024];
size_t recv_size = sizeof(recv_buffer) - 1;
size_t bytes_received = 0;
if (tcs_receive_from(socket, recv_buffer, recv_size, TCS_FLAG_NONE, &remote_address, &bytes_received) !=
TCS_SUCCESS)
size_t received_size = 0;
if (tcs_receive_from(socket, recv_buffer, recv_size, TCS_FLAG_NONE, &remote_address, &received_size) != TCS_SUCCESS)
return show_error("Could not receive data");

// Makes sure it is a NULL terminated string, this is why we only accept 1023 bytes in receive
recv_buffer[bytes_received] = '\0';
recv_buffer[received_size] = '\0';
printf("received: %s\n", recv_buffer);

char msg[] = "I hear you loud and clear\n";
Expand All @@ -60,6 +59,6 @@ int main(void)
if (tcs_close(&socket) != TCS_SUCCESS)
return show_error("Could not close socket");

if (tcs_lib_free() != TCS_SUCCESS)
if (tcs_lib_cleanup() != TCS_SUCCESS)
return show_error("Could not free tinycsocket");
}
Loading
Loading