#include <netinet/in.h>
#include <sys/epoll.h>
#include <sys/ioctl.h>
+#include <errno.h>
unsigned short port = 2007;
sin.sin_addr = destinations[dst_num];
// non-blocking connect (will be detected by epoll later)
- if (connect(sock, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
+ if (connect(sock, (struct sockaddr *)&sin, sizeof(sin)) == -1 && errno != EINPROGRESS) {
perror("connect()");
exit(1);
}
generate_new_sender(ep_fd);
for ( ;; ) {
- int ret = epoll_wait(ep_fd, events, num_sockets_per_sender, -1);
- for (i = 0; i < ret; ++i) {
+ int num_active = epoll_wait(ep_fd, events, num_sockets_per_sender, -1);
+ if (num_active == -1) {
+ perror("epoll_wait");
+ exit(1);
+ }
+
+ for (i = 0; i < num_active; ++i) {
unsigned bytes_to_send = events[i].data.u64;
unsigned ret;
if (destinations == NULL || sources == NULL) {
fprintf(stderr, "Missing or empty source or destination host list. Aborting.\n");
+ exit(1);
}
if (do_listen) {