aboutsummaryrefslogtreecommitdiff
path: root/network.F90
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2020-05-01 11:21:05 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2020-05-01 11:21:05 -0400
commitc7a908cc5adede6ca34519059f2e324dc6737ff6 (patch)
tree98a32e703bac397e37c38d1fdbfa16123e2d46af /network.F90
parent690395a50cd55401a9cfee598638bef482d164bd (diff)
downloadLR-87-c7a908cc5adede6ca34519059f2e324dc6737ff6.zip
LR-87-c7a908cc5adede6ca34519059f2e324dc6737ff6.tar.gz
SSL network connections now seem to work, including on windows
Diffstat (limited to 'network.F90')
-rw-r--r--network.F9048
1 files changed, 48 insertions, 0 deletions
diff --git a/network.F90 b/network.F90
index 2130841..2ad520b 100644
--- a/network.F90
+++ b/network.F90
@@ -56,6 +56,12 @@ implicit none
integer(c_int32_t)::inet_addr_c
end function inet_addr_c
+ function inet_ntoa_c(ip) bind(c, name="inet_ntoa")
+ use iso_c_binding
+ type(c_ptr)::inet_ntoa_c
+ integer(c_int32_t), value::ip
+ end function inet_ntoa_c
+
function htons(i) bind(c)
use iso_c_binding
integer(kind=c_int32_t), value::i
@@ -77,6 +83,12 @@ implicit none
type(c_ptr)::gethostbyname_c
end function gethostbyname_c
+ function close_c(s) bind(c, name="close")
+ use iso_c_binding
+ integer(kind=c_int), value::s
+ integer(kind=c_int)::close_c
+ end function close_c
+
end interface
contains
@@ -92,6 +104,17 @@ implicit none
end function socket
+ subroutine close_socket(s)
+ use iso_c_binding
+ implicit none
+
+ integer::s
+ integer::ignored
+
+ ignored = close_c(int(s, kind=c_int))
+
+ end subroutine close_socket
+
function inet_addr(str)
use iso_c_binding
implicit none
@@ -115,6 +138,31 @@ implicit none
end function inet_addr
+ function inet_ntoa(ip) result(res)
+ use iso_c_binding
+ implicit none
+
+ integer(kind=c_int32_t), intent(in)::ip
+ character(15)::res
+
+ type(c_ptr)::cptr
+ character(kind=c_char), dimension(:), pointer::cres
+ integer::i
+
+ res = " "
+ cptr = inet_ntoa_c(ip)
+ if(c_associated(cptr)) then
+ call c_f_pointer(cptr, cres, [1])
+
+ i = 1
+ do while(cres(i) /= c_null_char)
+ res(i:i) = cres(i)
+ i = i + 1
+ end do
+ end if
+
+ end function inet_ntoa
+
function connect(sockfd, sock_addr)
use iso_c_binding
implicit none