Add #define for listening on loopback or 0.0.0.0

This commit is contained in:
flyingscorpio@clevo 2022-10-19 22:55:51 +02:00
parent 8a965787a2
commit db9fbb9f22
2 changed files with 6 additions and 1 deletions

View file

@ -30,8 +30,11 @@ int main(void) {
#else
server_socket.sin_port = 0;
#endif
#ifdef LISTEN_ALL
server_socket.sin_addr.s_addr = makeip4(0, 0, 0, 0);
// server_socket.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
#else
server_socket.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
#endif
/* Define the socket */
if ((serv_sockid = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {

View file

@ -1,6 +1,8 @@
#ifndef SERVER_H
#define SERVER_H
#define LISTEN_ALL // define to listen on 0.0.0.0, else loopback
/* Handles a client after its connection */
void service(int);