+#include <assert.h>
+#include <errno.h>
+#include <poll.h>
#include <stdio.h>
-#include <sys/types.h>
+#include <stdlib.h>
#include <sys/socket.h>
-#include <sys/poll.h>
-#include <arpa/inet.h>
-#include <errno.h>
+#include <unistd.h>
#include <string>
#include "acceptor.h"
-#include "udpinput.h"
+#include "log.h"
#include "serverpool.h"
-#include "version.h"
#include "state.pb.h"
+#include "udpinput.h"
+#include "version.h"
using namespace std;
InputProto UDPInput::serialize() const
{
InputProto serialized;
+ serialized.set_stream_id(stream_id);
serialized.set_url(url);
serialized.set_sock(sock);
return serialized;
} while (ret == -1 && errno == EINTR);
if (ret == -1) {
- perror("close()");
+ log_perror("close()");
}
sock = -1;
int port_num = atoi(port.c_str());
sock = create_server_socket(port_num, UDP_SOCKET);
if (sock == -1) {
- fprintf(stderr, "WARNING: UDP socket creation failed. Waiting 0.2 seconds and trying again...\n");
+ log(WARNING, "[%s] UDP socket creation failed. Waiting 0.2 seconds and trying again...",
+ stream_id.c_str());
usleep(200000);
continue;
}
continue;
}
if (nfds == -1) {
- perror("poll");
+ log_perror("poll");
close_socket();
continue;
}
} while (ret == -1 && errno == EINTR);
if (ret <= 0) {
- perror("recv");
+ log_perror("recv");
close_socket();
continue;
}