Skip to content

Commit

Permalink
test/simulator/sock-util.c: IPv4 only
Browse files Browse the repository at this point in the history
For some testing the listening ports on the simulator
had been opened with AF_INET6.
Under Linux and MacOs thoses sockets accept IPV4 as well,
unless the socket had been bound to IPv4 already.
Then silently only IPv6 traffic is accepted.
The disadvantage here is that we fail, if e.g.
the ads-forwarder is running.

Another disadvantage is, that FreeBSD does not accept
IPv4 on such a socket, and that is what we need.

Solution: Open the socketswith AF_INET again.
When the day comes, that IPv6 is needed for the simulator,
more coding may be needed.
  • Loading branch information
tboegi committed Sep 12, 2024
1 parent b61e6ef commit 0f70dfd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/simulator/sock-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ void socket_loop(void) {
{
unsigned short port = 5000;
listen_socket =
epicsSocketCreateBind(AF_INET6, SOCK_STREAM, IPPROTO_TCP, port,
epicsSocketCreateBind(AF_INET, SOCK_STREAM, IPPROTO_TCP, port,
EPICSSOCKETENABLEADDRESSREUSE_FLAG);
if (listen_socket >= 0) {
LOGINFO("listening2 on port %d\n", port);
Expand All @@ -717,7 +717,7 @@ void socket_loop(void) {
{
unsigned short port = 48898;
listen_socket =
epicsSocketCreateBind(AF_INET6, SOCK_STREAM, IPPROTO_TCP, port,
epicsSocketCreateBind(AF_INET, SOCK_STREAM, IPPROTO_TCP, port,
EPICSSOCKETENABLEADDRESSREUSE_FLAG);
if (listen(listen_socket, 1) < 0) {
LOGERR_ERRNO("listen() failed\n");
Expand Down

0 comments on commit 0f70dfd

Please sign in to comment.