]> git.meshlink.io Git - utcp/blobdiff - test.c
Add a function to check for active connections.
[utcp] / test.c
diff --git a/test.c b/test.c
index 8ad46c63f49eada35109e303582ed121e8444953..0eb8462b4b60f26a17c87860384d238500748db8 100644 (file)
--- a/test.c
+++ b/test.c
@@ -39,6 +39,7 @@ ssize_t do_recv(struct utcp_connection *c, const void *data, size_t len) {
 void do_accept(struct utcp_connection *nc, uint16_t port) {
        utcp_accept(nc, do_recv, NULL);
        c = nc;
+       utcp_set_accept_cb(c->utcp, NULL, NULL);
 }
 
 ssize_t do_send(struct utcp *utcp, const void *data, size_t len) {
@@ -108,7 +109,7 @@ int main(int argc, char *argv[]) {
        char buf[102400];
        struct timeval timeout = utcp_timeout(u);
 
-       while(dir) {
+       while(!connected || utcp_is_active(u)) {
                size_t max = c ? utcp_get_sndbuf_free(c) : 0;
                if(max > sizeof buf)
                        max = sizeof buf;