X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Futcp-test.c;h=564bfba8618472fdcffe646d9dcb54efeb937ce4;hb=HEAD;hp=d1fb606fe31a822da7495d1222f505f9f1a99a19;hpb=deb85047ebc713f0de6b14ac2c5918e5bbb6425d;p=meshlink diff --git a/src/utcp-test.c b/src/utcp-test.c index d1fb606f..a7c0534f 100644 --- a/src/utcp-test.c +++ b/src/utcp-test.c @@ -105,8 +105,8 @@ static void do_accept(struct utcp_connection *nc, uint16_t port) { c = nc; if(bufsize) { - utcp_set_sndbuf(c, bufsize); - utcp_set_rcvbuf(c, bufsize); + utcp_set_sndbuf(c, NULL, bufsize); + utcp_set_rcvbuf(c, NULL, bufsize); } utcp_set_accept_cb(c->utcp, NULL, NULL); @@ -157,11 +157,17 @@ static ssize_t do_send(struct utcp *utcp, const void *data, size_t len) { } static void set_mtu(struct utcp *u, int s) { +#ifdef IP_MTU + if(!mtu) { socklen_t optlen = sizeof(mtu); getsockopt(s, IPPROTO_IP, IP_MTU, &mtu, &optlen); } +#else + (void)s; +#endif + if(!mtu || mtu == 65535) { mtu = 1500; } @@ -264,6 +270,11 @@ int main(int argc, char *argv[]) { return 1; } } else { +#ifdef SO_NOSIGPIPE + int nosigpipe = 1; + setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe)); +#endif + if(connect(s, ai->ai_addr, ai->ai_addrlen)) { debug("Could not connect: %s\n", strerror(errno)); return 1; @@ -288,8 +299,8 @@ int main(int argc, char *argv[]) { c = utcp_connect_ex(u, 1, do_recv, NULL, flags); if(bufsize) { - utcp_set_sndbuf(c, bufsize); - utcp_set_rcvbuf(c, bufsize); + utcp_set_sndbuf(c, NULL, bufsize); + utcp_set_rcvbuf(c, NULL, bufsize); } }