]> git.meshlink.io Git - utcp/blobdiff - selftest.c
Various small fixes, clarifications.
[utcp] / selftest.c
index 2c299437388e3d6cef3700860f7f3397bd6a70ea..f6e4c8c4ce5abfa488964fca5776282fe46d58c3 100644 (file)
@@ -10,7 +10,7 @@ struct utcp *a;
 struct utcp *b;
 struct utcp_connection *c;
 
-int do_recv(struct utcp_connection *x, const void *data, size_t len) {
+ssize_t do_recv(struct utcp_connection *x, const void *data, size_t len) {
        if(!len) {
                if(errno)
                        fprintf(stderr, "%p Error: %s\n", x->utcp, strerror(errno));
@@ -24,11 +24,9 @@ int do_recv(struct utcp_connection *x, const void *data, size_t len) {
        }
 
        if(x == c)
-               write(0, data, len);
+               return write(0, data, len);
        else
-               utcp_send(x, data, len);
-
-       return 0;
+               return utcp_send(x, data, len);
 }
 
 bool do_pre_accept(struct utcp *utcp, uint16_t port) {
@@ -43,7 +41,7 @@ void do_accept(struct utcp_connection *c, uint16_t port) {
        utcp_accept(c, do_recv, NULL);
 }
 
-int do_send(struct utcp *utcp, const void *data, size_t len) {
+ssize_t do_send(struct utcp *utcp, const void *data, size_t len) {
        static int count = 0;
        if(++count > 1000) {
                fprintf(stderr, "Too many packets!\n");