forked from patmarion/ParaViewAutoBuild
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbgl-sockets.patch
95 lines (91 loc) · 2.73 KB
/
bgl-sockets.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
diff --git a/VTK/Common/vtkSocket.cxx b/VTK/Common/vtkSocket.cxx
index d85dacf..abbe57f 100644
--- a/VTK/Common/vtkSocket.cxx
+++ b/VTK/Common/vtkSocket.cxx
@@ -16,6 +16,10 @@
#include "vtkObjectFactory.h"
+#ifdef __blrts__
+#include <cstdio>
+#endif
+
// The VTK_SOCKET_FAKE_API definition is given to the compiler
// command line by CMakeLists.txt if there is no real sockets
// interface available. When this macro is defined we simply make
@@ -24,6 +28,10 @@
// Perhaps we should add a method to query at runtime whether a real
// sockets interface is available.
+#ifdef __blrts__ //BlueGene/L
+#undef VTK_SOCKET_FAKE_API
+#endif
+
#ifndef VTK_SOCKET_FAKE_API
#if defined(_WIN32) && !defined(__CYGWIN__)
#define VTK_WINDOWS_FULL
@@ -77,10 +85,14 @@ int vtkSocket::CreateSocket()
int sock = socket(AF_INET, SOCK_STREAM, 0);
// Elimate windows 0.2 second delay sending (buffering) data.
int on = 1;
+#ifdef __blrts__
+ //BG/L tuning here? setsockopt() isn't supported
+#else
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&on, sizeof(on)))
{
return -1;
}
+#endif
return sock;
#else
return -1;
@@ -167,7 +179,11 @@ int vtkSocket::SelectSocket(int socketdescriptor, unsigned long msec)
}
FD_ZERO(&rset);
FD_SET(socketdescriptor, &rset);
+#ifdef __blrts__
+ int res=1; //no select on BG/L, so poll
+#else
int res = select(socketdescriptor + 1, &rset, 0, 0, tvalptr);
+#endif
if(res == 0)
{
return 0;//for time limit expire
@@ -215,8 +231,11 @@ int vtkSocket::SelectSockets(const int* sockets_to_select, int size,
FD_SET(sockets_to_select[i],&rset);
max_fd = (sockets_to_select[i] > max_fd)? sockets_to_select[i] : max_fd;
}
-
+#ifdef __blrts__
+ int res = 1; //no select on BG/L
+#else
int res = select(max_fd + 1, &rset, 0, 0, tvalptr);
+#endif
if (res == 0)
{
return 0; //Timeout
@@ -254,7 +273,15 @@ int vtkSocket::Connect(int socketdescriptor, const char* hostName, int port)
{
return -1;
}
-
+#ifdef __blrts__
+ //BG/L doesn't support DNS so we need an IP address
+ unsigned char addr[4];
+ sscanf(hostName,"%hhd.%hhd.%hhd.%hhd",
+ &(addr[0]),&(addr[1]),&(addr[2]),&(addr[3]));
+ struct sockaddr_in name;
+ name.sin_family = AF_INET;
+ memcpy(&name.sin_addr,addr,4);
+#else
struct hostent* hp;
hp = gethostbyname(hostName);
if (!hp)
@@ -268,10 +295,10 @@ int vtkSocket::Connect(int socketdescriptor, const char* hostName, int port)
// vtkErrorMacro("Unknown host: " << hostName);
return -1;
}
-
struct sockaddr_in name;
name.sin_family = AF_INET;
memcpy(&name.sin_addr, hp->h_addr, hp->h_length);
+#endif
name.sin_port = htons(port);
return connect(socketdescriptor, reinterpret_cast<sockaddr*>(&name),