.sin6_port = htons(port),
};
+ // Set socket buffer sizes
+ int r = set_socket_buffer_sizes(conf, fd);
+ if (r)
+ goto ERROR;
+
// Enable keepalive
int flags = 1;
- int r = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void*)&flags, sizeof(flags));
+ r = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void*)&flags, sizeof(flags));
if (r) {
ERROR(conf, "Could not set SO_KEEPALIVE on socket %d: %s\n",
fd, strerror(errno));
goto ERROR;
}
- // Set socket buffer sizes
- flags = SOCKET_SEND_BUFFER_SIZE;
- r = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void*)&flags, sizeof(flags));
- if (r) {
- ERROR(conf, "Could not set send buffer size on socket %d: %s\n",
- fd, strerror(errno));
- goto ERROR;
- }
-
// Set keepalive interval
if (conf->keepalive_interval) {
DEBUG(conf, "Setting keepalive interval to %d\n", conf->keepalive_interval);
return 0;
}
+int set_socket_buffer_sizes(struct fireperf_config* conf, int fd) {
+ int r;
+
+ // Set socket buffer sizes
+ int flags = SOCKET_SEND_BUFFER_SIZE;
+ r = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void*)&flags, sizeof(flags));
+ if (r) {
+ ERROR(conf, "Could not set send buffer size on socket %d: %s\n",
+ fd, strerror(errno));
+ return 1;
+ }
+
+ // Set receive buffer size
+ flags = SOCKET_RECV_BUFFER_SIZE;
+ r = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void*)&flags, sizeof(flags));
+ if (r) {
+ ERROR(conf, "Could not set receive buffer size on socket %d: %s\n",
+ fd, strerror(errno));
+ return 1;
+ }
+
+ return 0;
+}
+
int handle_connection_send(struct fireperf_config* conf,
struct fireperf_stats* stats, int fd) {
const char* buffer = ZERO;
int fireperf_dump_stats(struct fireperf_config* conf, struct fireperf_stats* stats, int mode);
+int set_socket_buffer_sizes(struct fireperf_config* conf, int fd);
+
int handle_connection_send(struct fireperf_config* conf,
struct fireperf_stats* stats, int fd);
int handle_connection_recv(struct fireperf_config* conf,
goto ERROR;
}
- // Set receive buffer size
- flags = SOCKET_RECV_BUFFER_SIZE;
- r = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void*)&flags, sizeof(flags));
- if (r) {
- ERROR(conf, "Could not set receive buffer size on socket %d: %s\n",
- fd, strerror(errno));
+ // Set socket buffer sizes
+ r = set_socket_buffer_sizes(conf, fd);
+ if (r)
goto ERROR;
- }
struct sockaddr_in6 addr = {
.sin6_family = AF_INET6,