8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No need to use getaddrinfo dance. This would be enough (feel free to reuse https://github.com/matu3ba/dotfiles/blob/2374f5ab126e8d47f4cc3ae86eb576197c31e8a3/templates/server.c):
int addr_family; //int ip_protocol; struct sockaddr_in6 source_addr = {}; // can contain Ipv4 and Ipv6 memset(&source_addr, 0, sizeof(source_addr)); //struct in_addr source_addr; struct sockaddr_in6 dest_addr = {}; memset(&dest_addr, 0, sizeof(dest_addr)); dest_addr.sin6_family = AF_INET6; dest_addr.sin6_port = htons(port); addr_family = AF_INET6; *listenfd = socket(addr_family, SOCK_STREAM, 0); if (listenfd < 0) { perror("unable to create socket"); exit(1); } // 1 - on, 0 - off int opt_REUSEADDR = 1; int opt_NODELAY = 1; int st = setsockopt(*listenfd, SOL_SOCKET, SO_REUSEADDR, &opt_REUSEADDR, sizeof(opt_REUSEADDR)); if (st < 0) { perror("set socket option SO_REUSEADDR failed"); close(*listenfd); exit(1); } st = setsockopt(*listenfd, IPPROTO_TCP, TCP_NODELAY, &opt_NODELAY, sizeof(opt_NODELAY)); if (st < 0) { perror("set socket option TCP_NODELAY failed"); close(*listenfd); exit(1); } st = bind(*listenfd, (struct sockaddr*) &dest_addr, sizeof(dest_addr)); if (st != 0) { perror("unable to bind socket"); close(*listenfd); exit(1); }
The text was updated successfully, but these errors were encountered:
Thanks! We will incorperate this in the next iteration 🕺
Sorry, something went wrong.
No branches or pull requests
No need to use getaddrinfo dance. This would be enough (feel free to reuse https://github.com/matu3ba/dotfiles/blob/2374f5ab126e8d47f4cc3ae86eb576197c31e8a3/templates/server.c):
The text was updated successfully, but these errors were encountered: