diff options
author | Christian Pointner <equinox@spreadspace.org> | 2010-11-28 21:49:51 +0000 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2010-11-28 21:49:51 +0000 |
commit | 21203e393c36d9c079491fb0644b9bce32f71758 (patch) | |
tree | d65a1ff398c29e9c7fb398544c266ccafd14acc1 /src/tcpproxy.c | |
parent | one side of cleint connections works for recv (diff) |
first minial version working
git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@12 e61f0598-a718-4e21-a8f0-0aadfa62ad6b
Diffstat (limited to 'src/tcpproxy.c')
-rw-r--r-- | src/tcpproxy.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/tcpproxy.c b/src/tcpproxy.c index fce2e2c..6a55ea1 100644 --- a/src/tcpproxy.c +++ b/src/tcpproxy.c @@ -52,13 +52,15 @@ int main_loop(options_t* opt, listeners_t* listeners) int return_value = clients_init(&clients); while(!return_value) { - fd_set readfds; + fd_set readfds, writefds; FD_ZERO(&readfds); + FD_ZERO(&writefds); FD_SET(sig_fd, &readfds); int nfds = sig_fd; listener_read_fds(listeners, &readfds, &nfds); clients_read_fds(&clients, &readfds, &nfds); - int ret = select(nfds + 1, &readfds, NULL, NULL, NULL); + clients_write_fds(&clients, &writefds, &nfds); + int ret = select(nfds + 1, &readfds, &writefds, NULL, NULL); if(ret == -1 && errno != EINTR) { log_printf(ERROR, "select returned with error: %s", strerror(errno)); return_value = -1; @@ -77,6 +79,9 @@ int main_loop(options_t* opt, listeners_t* listeners) return_value = listener_handle_accept(listeners, &clients, &readfds); if(return_value) break; + return_value = clients_write(&clients, &writefds); + if(return_value) break; + return_value = clients_read(&clients, &readfds); } |