diff --git a/examples/tcp_chat_server.c b/examples/tcp_chat_server.c index 2fe688b04..edfa9b1c7 100644 --- a/examples/tcp_chat_server.c +++ b/examples/tcp_chat_server.c @@ -13,6 +13,11 @@ #include "hbase.h" #include "list.h" +// hloop_create_tcp_server +// on_accept => join +// on_recv => broadcast +// on_close => leave + typedef struct chatroom_s { hloop_t* loop; hio_t* listenio; diff --git a/examples/tcp_echo_server.c b/examples/tcp_echo_server.c index a497193b9..4c7572de9 100644 --- a/examples/tcp_echo_server.c +++ b/examples/tcp_echo_server.c @@ -11,6 +11,8 @@ #include "hloop.h" #include "hsocket.h" +// hloop_create_tcp_server -> on_accept -> hio_read -> on_recv -> hio_write + static void on_close(hio_t* io) { printf("on_close fd=%d error=%d\n", hio_fd(io), hio_error(io)); } diff --git a/examples/tcp_proxy_server.c b/examples/tcp_proxy_server.c index d8e93ca23..3f969ae45 100644 --- a/examples/tcp_proxy_server.c +++ b/examples/tcp_proxy_server.c @@ -1,7 +1,7 @@ /* * tcp proxy server * - * @test: make examples + * @build: make examples * @http_server: bin/httpd -d * @proxy_server: bin/tcp_proxy_server 1234 127.0.0.1:8080 * bin/tcp_proxy_server 1234 www.baidu.com @@ -18,12 +18,13 @@ #include "hloop.h" #include "hsocket.h" -// hloop_create_tcp_server => on_accept(connio) => proxyio = hloop_create_tcp_client -// on_proxy_connect => hio_read(connio) hio_read(proxyio) +// hloop_create_tcp_server +// on_accept(connio) => proxyio = hloop_create_tcp_client +// on_proxy_connect(proxyio) => hio_read(connio) hio_read(proxyio) // on_recv(connio) => hio_write(proxyio) // on_proxy_recv(proxyio) => hio_write(connio) // on_close(connio) => hio_close(proxyio) -// on_proxy(proxyio) => hio_close(connio) +// on_proxy_close(proxyio) => hio_close(connio) static char proxy_host[64] = "127.0.0.1"; static int proxy_port = 80;