diff options
author | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-04-16 11:33:11 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeff@approximatrix.com> | 2021-04-16 11:33:11 -0400 |
commit | a60a9d10ce94acc0c5bfed2a20c8bed4e91be725 (patch) | |
tree | 59cfacd7c0460817b434768fac12a8c56ae2c946 /common | |
parent | efb5d8cec9531637c91fc1087f9c83b4d89a5612 (diff) | |
download | levitating-a60a9d10ce94acc0c5bfed2a20c8bed4e91be725.tar.gz levitating-a60a9d10ce94acc0c5bfed2a20c8bed4e91be725.zip |
Fixed issue with connect calls that were manifested on macOS.
Diffstat (limited to 'common')
-rw-r--r-- | common/network.F90 | 19 | ||||
-rw-r--r-- | common/protocol.f90 | 2 | ||||
-rw-r--r-- | common/request.f90 | 5 | ||||
-rw-r--r-- | common/testnum.c | 11 |
4 files changed, 34 insertions, 3 deletions
diff --git a/common/network.F90 b/common/network.F90 index f986275..8cefd1a 100644 --- a/common/network.F90 +++ b/common/network.F90 @@ -72,7 +72,7 @@ implicit none end type #endif - integer(kind=c_size_t), parameter::sockaddr_size = 56 + integer(kind=c_size_t), parameter::sockaddr_size = 16 interface function socket_c(i, j, k) bind(c, name="socket") @@ -120,6 +120,18 @@ implicit none integer(kind=c_int)::close_c end function close_c + !subroutine memset_c(p, v, n) bind(c, name="memset") + !use iso_c_binding + !type(c_ptr), value::p + !integer(kind=c_int), value::v, n + !end subroutine memset_c + + ! Debugging routine + !subroutine output_sa(p) bind(c, name="output_sa") + !use iso_c_binding + !type(c_ptr), value::p + !end subroutine output_sa + end interface contains @@ -237,7 +249,10 @@ implicit none integer::sockfd type(sockaddr_in), target::sock_addr logical::connect - + + ! Just for debugging + !call output_sa(c_loc(sock_addr)) + connect = (connect_c(int(sockfd, kind=c_int), & c_loc(sock_addr), & sockaddr_size) .eq. 0) diff --git a/common/protocol.f90 b/common/protocol.f90 index 46838b8..cf93b0d 100644 --- a/common/protocol.f90 +++ b/common/protocol.f90 @@ -197,6 +197,8 @@ contains else + Print *, "Connection Failed with Code: ", conn%code + returncode = STATUS_CONNECTFAIL end if diff --git a/common/request.f90 b/common/request.f90 index fe4d970..ce81ae6 100644 --- a/common/request.f90 +++ b/common/request.f90 @@ -90,7 +90,7 @@ contains type(c_ptr)::ssl_method conn%code = CONNECTION_NONE - + ! Lookup host conn%host = gethostbyname(server) if((.not. allocated(conn%host%h_name)) .or. (conn%host%h_addr4 == 0)) then @@ -106,8 +106,11 @@ contains else sa%sin_port = htons(1965) end if + conn%socket = socket(AF_INET, SOCK_STREAM, 0) + if(.not. connect(conn%socket, sa)) then + Print *, "Errno is ", ierrno() conn%code = CONNECTION_SOCKET_FAILURE return end if diff --git a/common/testnum.c b/common/testnum.c new file mode 100644 index 0000000..0d6715b --- /dev/null +++ b/common/testnum.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <netinet/in.h> + +void output_sa(struct sockaddr_in *sa) +{ + printf("sin_len is %d\n", sa->sin_len); + printf("sin_family is %d\n", sa->sin_family); + printf("sin_port is %d\n", sa->sin_port); + printf("sin_addr is %d\n", sa->sin_addr.s_addr); + printf("sizeof is %lu\n", sizeof(sa)); +} |