samples: net: Rename local PORT definition

This commit renames all local definitions with the name `PORT` in the
net samples, in order to prevent name conflict with certain HALs
(notably, Atmel SAM E5x HAL).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2020-04-27 16:38:49 +09:00 committed by Jukka Rissanen
commit 460cb7880c
5 changed files with 24 additions and 19 deletions

View file

@ -24,7 +24,7 @@
#endif
#define PORT 8080
#define BIND_PORT 8080
#ifndef USE_BIG_PAYLOAD
#define USE_BIG_PAYLOAD 1
@ -52,12 +52,13 @@ void main(void)
bind_addr.sin_family = AF_INET;
bind_addr.sin_addr.s_addr = htonl(INADDR_ANY);
bind_addr.sin_port = htons(PORT);
bind_addr.sin_port = htons(BIND_PORT);
CHECK(bind(serv, (struct sockaddr *)&bind_addr, sizeof(bind_addr)));
CHECK(listen(serv, 5));
printf("Single-threaded dumb HTTP server waits for a connection on port %d...\n", PORT);
printf("Single-threaded dumb HTTP server waits for a connection on "
"port %d...\n", BIND_PORT);
while (1) {
struct sockaddr_in client_addr;

View file

@ -22,7 +22,7 @@
#endif
#define PORT 4242
#define BIND_PORT 4242
void main(void)
{
@ -39,7 +39,7 @@ void main(void)
bind_addr.sin_family = AF_INET;
bind_addr.sin_addr.s_addr = htonl(INADDR_ANY);
bind_addr.sin_port = htons(PORT);
bind_addr.sin_port = htons(BIND_PORT);
if (bind(serv, (struct sockaddr *)&bind_addr, sizeof(bind_addr)) < 0) {
printf("error: bind: %d\n", errno);
@ -51,7 +51,8 @@ void main(void)
exit(1);
}
printf("Single-threaded TCP echo server waits for a connection on port %d...\n", PORT);
printf("Single-threaded TCP echo server waits for a connection on "
"port %d...\n", BIND_PORT);
while (1) {
struct sockaddr_in client_addr;

View file

@ -39,7 +39,7 @@
#define NUM_FDS 5
#endif
#define PORT 4242
#define BIND_PORT 4242
/* Number of simultaneous client connections will be NUM_FDS be minus 2 */
struct pollfd pollfds[NUM_FDS];
@ -112,7 +112,7 @@ void main(void)
int serv4;
struct sockaddr_in bind_addr4 = {
.sin_family = AF_INET,
.sin_port = htons(PORT),
.sin_port = htons(BIND_PORT),
.sin_addr = {
.s_addr = htonl(INADDR_ANY),
},
@ -121,7 +121,7 @@ void main(void)
int serv6;
struct sockaddr_in6 bind_addr6 = {
.sin6_family = AF_INET6,
.sin6_port = htons(PORT),
.sin6_port = htons(BIND_PORT),
.sin6_addr = IN6ADDR_ANY_INIT,
};
#endif
@ -170,7 +170,8 @@ void main(void)
pollfds_add(serv6);
#endif
printf("Asynchronous TCP echo server waits for connections on port %d...\n", PORT);
printf("Asynchronous TCP echo server waits for connections on "
"port %d...\n", BIND_PORT);
while (1) {
struct sockaddr_storage client_addr;

View file

@ -33,7 +33,7 @@
#define NUM_FDS 5
#endif
#define PORT 4242
#define BIND_PORT 4242
/* Number of simultaneous client connections will be NUM_FDS be minus 2 */
fd_set readfds;
@ -90,14 +90,14 @@ void main(void)
int serv4, serv6;
struct sockaddr_in bind_addr4 = {
.sin_family = AF_INET,
.sin_port = htons(PORT),
.sin_port = htons(BIND_PORT),
.sin_addr = {
.s_addr = htonl(INADDR_ANY),
},
};
struct sockaddr_in6 bind_addr6 = {
.sin6_family = AF_INET6,
.sin6_port = htons(PORT),
.sin6_port = htons(BIND_PORT),
.sin6_addr = IN6ADDR_ANY_INIT,
};
@ -143,7 +143,8 @@ void main(void)
pollfds_add(serv4);
pollfds_add(serv6);
printf("Async select-based TCP echo server waits for connections on port %d...\n", PORT);
printf("Async select-based TCP echo server waits for connections on "
"port %d...\n", BIND_PORT);
while (1) {
struct sockaddr_storage client_addr;

View file

@ -15,7 +15,7 @@ LOG_MODULE_REGISTER(net_websocket_client_sample, LOG_LEVEL_DBG);
#include "ca_certificate.h"
#define PORT 9001
#define SERVER_PORT 9001
#if defined(CONFIG_NET_CONFIG_PEER_IPV6_ADDR)
#define SERVER_ADDR6 CONFIG_NET_CONFIG_PEER_IPV6_ADDR
@ -345,13 +345,13 @@ void main(void)
}
if (IS_ENABLED(CONFIG_NET_IPV4)) {
(void)connect_socket(AF_INET, SERVER_ADDR4, PORT,
(void)connect_socket(AF_INET, SERVER_ADDR4, SERVER_PORT,
&sock4, (struct sockaddr *)&addr4,
sizeof(addr4));
}
if (IS_ENABLED(CONFIG_NET_IPV6)) {
(void)connect_socket(AF_INET6, SERVER_ADDR6, PORT,
(void)connect_socket(AF_INET6, SERVER_ADDR6, SERVER_PORT,
&sock6, (struct sockaddr *)&addr6,
sizeof(addr6));
}
@ -375,7 +375,8 @@ void main(void)
websock4 = websocket_connect(sock4, &req, timeout, "IPv4");
if (websock4 < 0) {
LOG_ERR("Cannot connect to %s:%d", SERVER_ADDR4, PORT);
LOG_ERR("Cannot connect to %s:%d", SERVER_ADDR4,
SERVER_PORT);
close(sock4);
}
}
@ -395,7 +396,7 @@ void main(void)
websock6 = websocket_connect(sock6, &req, timeout, "IPv6");
if (websock6 < 0) {
LOG_ERR("Cannot connect to [%s]:%d", SERVER_ADDR6,
PORT);
SERVER_PORT);
close(sock6);
}
}