aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2021-04-16 11:33:11 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2021-04-16 11:33:11 -0400
commita60a9d10ce94acc0c5bfed2a20c8bed4e91be725 (patch)
tree59cfacd7c0460817b434768fac12a8c56ae2c946
parentefb5d8cec9531637c91fc1087f9c83b4d89a5612 (diff)
downloadlevitating-a60a9d10ce94acc0c5bfed2a20c8bed4e91be725.tar.gz
levitating-a60a9d10ce94acc0c5bfed2a20c8bed4e91be725.zip
Fixed issue with connect calls that were manifested on macOS.
-rw-r--r--common/network.F9019
-rw-r--r--common/protocol.f902
-rw-r--r--common/request.f905
-rw-r--r--common/testnum.c11
-rw-r--r--player/levitating-player.prj109
-rw-r--r--player/player.F903
-rw-r--r--player/talking.f901
7 files changed, 94 insertions, 56 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));
+}
diff --git a/player/levitating-player.prj b/player/levitating-player.prj
index fef15ef..7e1cc28 100644
--- a/player/levitating-player.prj
+++ b/player/levitating-player.prj
@@ -1,8 +1,26 @@
{
"Root":{
+ "Files":[{
+ "filename":"config.f90",
+ "enabled":"1"
+ },{
+ "filename":"endpoints.f90",
+ "enabled":"1"
+ },{
+ "filename":"instructions.f90",
+ "enabled":"1"
+ },{
+ "filename":"player.F90",
+ "enabled":"1"
+ },{
+ "filename":"talking.f90",
+ "enabled":"1"
+ },{
+ "filename":"tasks.f90",
+ "enabled":"1"
+ }],
+ "Name":"+levitating-player (levitating-player)",
"Folders":[{
- "Folders":[],
- "Name":"+common",
"Files":[{
"filename":"../common/jessl.f90",
"enabled":"1"
@@ -16,87 +34,72 @@
"filename":"../common/request.f90",
"enabled":"1"
},{
+ "filename":"../common/testnum.c",
+ "enabled":"0"
+ },{
"filename":"../common/utilities.F90",
"enabled":"1"
},{
"filename":"../common/wsa.f90",
"enabled":"0"
- }]
- }],
- "Name":"+levitating-player (levitating-player.exe)",
- "Files":[{
- "filename":"config.f90",
- "enabled":"1"
- },{
- "filename":"endpoints.f90",
- "enabled":"1"
- },{
- "filename":"instructions.f90",
- "enabled":"1"
- },{
- "filename":"player.F90",
- "enabled":"1"
- },{
- "filename":"talking.f90",
- "enabled":"1"
- },{
- "filename":"tasks.f90",
- "enabled":"1"
+ }],
+ "Name":"+common",
+ "Folders":[]
}]
},
- "Name":"levitating-player (levitating-player.exe)",
+ "Name":"levitating-player (levitating-player)",
"Options":{
"Compiler Options":{
- "Fortran Flags":"-DGNU",
"Link Flags":"-ljsonfortran -lssl -lcrypto",
- "C Flags":""
+ "C Flags":"",
+ "Fortran Flags":"-DGNU"
},
- "Architecture":1,
- "Type":0,
"Revision":2,
- "Windows GUI":0,
- "File Options":{
- "Library Directories":["Default Add-On Directory","../support/lib"],
- "Build Directory":"build",
- "Module Directory":"modules",
- "Include Directories":["Default Add-On Include Directory","../support/include"]
- },
- "Target":"levitating-player.exe",
"Fortran Options":{
- "Use C Preprocessor":"false",
- "Runtime Diagnostics":"false",
- "Floating Point Exception Trap":0,
- "Cray Pointers":"false",
"Enable Coarrays":"false",
+ "Cray Pointers":"false",
+ "Runtime Diagnostics":"false",
"Enable OpenMP":"false",
"Initialize Variables to Zero":"false",
- "Default Double for Real":"false"
+ "Floating Point Exception Trap":0,
+ "Default Double for Real":"false",
+ "Use C Preprocessor":"false"
},
"Code Generation Options":{
- "CPU Specific":"false",
- "Processor":"generic",
- "Aggressive Loops":"false",
"Debugging":"true",
+ "Profiling":"false",
"Optimization Mode":0,
- "Profiling":"false"
+ "Aggressive Loops":"false",
+ "Processor":"generic",
+ "CPU Specific":"false"
},
- "Build Dependencies":1,
"Launch Options":{
- "Working Directory":"/tmp/example",
- "Launch Using MPI":"false",
- "Keep Console":"true",
- "External Console":"false",
"Command Line Arguments":"-i windows-1 -l /tmp/player.log -w /tmp/example 127.0.0.1",
- "Build Before Launch":"true"
+ "External Console":"false",
+ "Keep Console":"true",
+ "Launch Using MPI":"false",
+ "Build Before Launch":"true",
+ "Working Directory":"/tmp/example"
},
"Build Options":{
"Makefile":"Makefile",
"Auto Makefile":"true"
},
+ "Type":0,
+ "Build Dependencies":1,
"Linker Options":{
"Static Linking Mode":3,
- "Link MPI Library":"false",
- "Link LAPACK":0
+ "Link LAPACK":0,
+ "Link MPI Library":"false"
+ },
+ "Target":"levitating-player",
+ "Architecture":1,
+ "Windows GUI":0,
+ "File Options":{
+ "Module Directory":"modules",
+ "Library Directories":["Default Add-On Directory","../support/lib","/opt/homebrew/opt/openssl@1.1/lib"],
+ "Build Directory":"build",
+ "Include Directories":["Default Add-On Include Directory","../support/include"]
}
}
} \ No newline at end of file
diff --git a/player/player.F90 b/player/player.F90
index dc05619..49803c5 100644
--- a/player/player.F90
+++ b/player/player.F90
@@ -58,6 +58,9 @@ implicit none
checkin_json_available = request_json(url, j_checkin)
if(checkin_json_available) then
work_to_do = work_available(j_checkin)
+ else
+ Print *, "Checkin failed: "//trim(url)
+ work_to_do = .false.
end if
if(work_to_do) then
diff --git a/player/talking.f90 b/player/talking.f90
index c33e059..42b6451 100644
--- a/player/talking.f90
+++ b/player/talking.f90
@@ -51,6 +51,7 @@ contains
status_code = request_url(mod_url, unit_number, return_type)
else
status_code = STATUS_LOCALFAIL
+ Print *, "Failed to open: "//trim(filename)
end if
close(unit_number)