Commit b7b745c1 authored by Heiko Liermann's avatar Heiko Liermann
Browse files

bug fix sin6_len

parent ae9e095a
......@@ -48,7 +48,9 @@ int main(int argc, char **argv) {
server_addr.sin6_family = AF_INET6;
server_addr.sin6_addr = in6addr_any;
server_addr.sin6_port = htons(strtol(argv[1], NULL, 10));
#ifdef HAVE_SIN_LEN
server_addr.sin6_len = sizeof(struct sockaddr_in);
#endif
setsockopt_wrap(server_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(int));
//accept Ipv4 and Ipv6
setsockopt_wrap(server_fd, IPPROTO_IPV6, IPV6_V6ONLY, &off, sizeof(int));
......
......@@ -5,7 +5,7 @@
#include <unistd.h>
int main(int argc, char **argv) {
int fd, stdin_open = 0;
int fd = -1, stdin_open = 0;
fd_set rset;
ssize_t len;
char buf[BUFFER_SIZE];
......@@ -55,7 +55,7 @@ int main(int argc, char **argv) {
//kann ich was von stin oder TCP Verbindung lesen?
FD_SET(fd, &rset); //TCP Verbindung
//Größter fd +1 , Readset intessiert uns
//Größter fd +1, Readset intessiert uns
select(fd + 1, &rset, NULL, NULL, NULL);
//0 ist lesbar, also wenn von stdin was lesbar ist
......
......@@ -19,6 +19,9 @@ main(int argc, char **argv)
server_addr.sin6_family = AF_INET6;
server_addr.sin6_addr = in6addr_any;
server_addr.sin6_port = htons(strtol(argv[1], NULL, 10));
#ifdef HAVE_SIN_LEN
server_addr.sin6_len = sizeof(struct sockaddr_in);
#endif
setsockopt_wrap(server_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(int));
//accept Ipv4 and Ipv6
......
......@@ -5,19 +5,22 @@
#include "Socket.h"
int main(int argc, char **argv) {
int i, server_fd, client_fd, nfds, len, on= 1, off = 0;
int i, server_fd, client_fd, nfds, on= 1, off = 0;
long len;
struct sockaddr_in6 server_addr;
int client_fds[30];
char buf[BUFFER_SIZE];
fd_set read_set, whole_set;
//(1)The creation of the TCP socket is identical to the client code
server_fd = socket_wrapper(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
nfds = server_fd = socket_wrapper(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
memset(&server_addr, 0, sizeof(server_addr));
server_addr.sin6_family = AF_INET6;
server_addr.sin6_addr = in6addr_any;
server_addr.sin6_port = htons(strtol(argv[1], NULL, 10));
#ifdef HAVE_SIN_LEN
server_addr.sin6_len = sizeof(struct sockaddr_in);
#endif
setsockopt_wrap(server_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(int));
//accept Ipv4 and Ipv6
setsockopt_wrap(server_fd, IPPROTO_IPV6, IPV6_V6ONLY, &off, sizeof(int));
......
......@@ -22,7 +22,7 @@ int main (int argc, char **argv) {
server_addr.sin6_addr = in6addr_any;
server_addr.sin6_port = htons(strtol(argv[1], NULL, 10));
#ifdef HAVE_SIN_LEN
server_addr.sin_len = sizeof(struct sockaddr_in);
server_addr.sin6_len = sizeof(struct sockaddr_in);
#endif
setsockopt_wrap(server_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(int));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment