Skip to content

Commit

Permalink
Merge pull request #127 from Monarda/openvms_posix_sockets
Browse files Browse the repository at this point in the history
Switch from fcntl to ioctl on OpenVMS for posix_sockets.h
  • Loading branch information
LiamBindle authored Mar 10, 2021
2 parents 229a907 + 0df6478 commit e44bef9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/templates/posix_sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <sys/socket.h>
#include <netdb.h>
#endif
#if defined(__VMS)
#include <ioctl.h>
#endif
#include <fcntl.h>

/*
Expand Down Expand Up @@ -55,6 +58,15 @@ int open_nb_socket(const char* addr, const char* port) {
ioctlsocket(sockfd, FIONBIO, &iMode);
}
#endif
#if defined(__VMS)
/*
OpenVMS only partially implements fcntl. It works on file descriptors
but silently fails on socket descriptors. So we need to fall back on
to the older ioctl system to set non-blocking IO
*/
int on = 1;
if (sockfd != -1) ioctl(sockfd, FIONBIO, &on);
#endif

/* return the new socket fd */
return sockfd;
Expand Down

0 comments on commit e44bef9

Please sign in to comment.