From 8b71f8b947807f6ecd7f99e808da1ff5b75754f2 Mon Sep 17 00:00:00 2001 From: lixianjing Date: Mon, 28 Aug 2023 11:59:57 +0800 Subject: [PATCH] improve tcp_send/tcp_recv args --- src/streams/tools/tcp_recv.c | 7 ++++--- src/streams/tools/tcp_send.c | 6 ++++-- sync_tkc.sh | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/streams/tools/tcp_recv.c b/src/streams/tools/tcp_recv.c index 1321d309e..38591810a 100644 --- a/src/streams/tools/tcp_recv.c +++ b/src/streams/tools/tcp_recv.c @@ -1,4 +1,4 @@ -#include "tkc/platform.h" +#include "tkc.h" #include "streams/inet/iostream_tcp.h" int main(int argc, char* argv[]) { @@ -6,13 +6,14 @@ int main(int argc, char* argv[]) { int32_t lsock = 0; tk_iostream_t* io = NULL; const char* response = "200 OK\n"; + int port = argc > 1 ? tk_atoi(argv[1]) : 8080; tk_socket_init(); platform_prepare(); - lsock = tk_tcp_listen(8080); + lsock = tk_tcp_listen(port); return_value_if_fail(lsock > 0, 0); - log_debug("listen at 8080...\n"); + log_debug("listen at %d...\n", port); while (1) { int32_t sock = 0; sock = tk_tcp_accept(lsock); diff --git a/src/streams/tools/tcp_send.c b/src/streams/tools/tcp_send.c index b4568956c..8ea7ea603 100644 --- a/src/streams/tools/tcp_send.c +++ b/src/streams/tools/tcp_send.c @@ -1,4 +1,4 @@ -#include "tkc/platform.h" +#include "tkc.h" #include "streams/inet/iostream_tcp.h" int main(int argc, char* argv[]) { @@ -6,10 +6,12 @@ int main(int argc, char* argv[]) { int32_t sock = 0; tk_iostream_t* io = NULL; const char* request = "GET / HTTP/1.1\r\nHost: localhost\r\n"; + const char* host = argc > 1 ? argv[1] : "localhost"; + int port = argc > 2 ? tk_atoi(argv[2]) : 8080; tk_socket_init(); platform_prepare(); - sock = tk_tcp_connect("localhost", 8080); + sock = tk_tcp_connect(host, port); return_value_if_fail(sock > 0, 0); io = tk_iostream_tcp_create(sock); diff --git a/sync_tkc.sh b/sync_tkc.sh index 506f3c4fb..3b9282483 100755 --- a/sync_tkc.sh +++ b/sync_tkc.sh @@ -16,4 +16,4 @@ done cp -rvf ../tkc/src/fscript_ext/*.* src/fscript_ext - +git checkout scripts/compile_config.py