nbeng

a non-blocking client/server engine
git clone git://git.2f30.org/nbeng
Log | Files | Refs | README

commit 9def2965ad257b6e18e18c3bf1556ccce5426837
parent 7490fb9056a808549f1b7eacc5fafedce7e0e1d6
Author: dsp <dsp@2f30.org>
Date:   Tue,  3 Jul 2012 21:34:07 +0300

bind works , SO_REUSEADDR needs the client to close first (TODO)

Diffstat:
Mnbeng.c | 18++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/nbeng.c b/nbeng.c @@ -126,18 +126,16 @@ prepare_socket(concontxt *con, char *host, char *port, int lflag) if (!p0) err(1, "socket"); /* the same for our local part */ - if (lflag) { - for (p0 = srv_servinfo; p0; p0 = p0->ai_next) { - if (bind(cli_sockfd, p0->ai_addr, p0->ai_addrlen) < 0) { - close(cli_sockfd); - warn("bind"); - continue; - } - break; + for (p0 = srv_servinfo; p0; p0 = p0->ai_next) { + if (bind(cli_sockfd, p0->ai_addr, p0->ai_addrlen) < 0) { + close(cli_sockfd); + warn("bind"); + continue; } - if (!p0) - err(1, "bind"); + break; } + if (!p0) + err(1, "bind"); /* if it's a tcp connection we have to listen() */ if (con->contype != UDPCON && lflag) listen(cli_sockfd, 5);