zeroc-ice 3.7.9.1 → 3.7.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/ext/ice/cpp/include/Ice/Config.h +5 -7
  3. data/ext/ice/cpp/include/Ice/ConsoleUtil.h +1 -1
  4. data/ext/ice/cpp/include/Ice/Ice.h +2 -2
  5. data/ext/ice/cpp/include/Ice/SHA1.h +0 -2
  6. data/ext/ice/cpp/include/IceSSL/IceSSL.h +3 -7
  7. data/ext/ice/cpp/include/IceUtil/Config.h +12 -44
  8. data/ext/ice/cpp/include/IceUtil/ConsoleUtil.h +1 -1
  9. data/ext/ice/cpp/include/IceUtil/FileUtil.h +0 -3
  10. data/ext/ice/cpp/include/IceUtil/IceUtil.h +1 -1
  11. data/ext/ice/cpp/include/IceUtil/Mutex.h +0 -4
  12. data/ext/ice/cpp/include/IceUtil/ResourceConfig.h +5 -21
  13. data/ext/ice/cpp/include/IceUtil/Thread.h +4 -18
  14. data/ext/ice/cpp/include/IceUtil/Timer.h +1 -0
  15. data/ext/ice/cpp/include/generated/Ice/BuiltinSequences.h +2 -2
  16. data/ext/ice/cpp/include/generated/Ice/Communicator.h +2 -2
  17. data/ext/ice/cpp/include/generated/Ice/CommunicatorF.h +2 -2
  18. data/ext/ice/cpp/include/generated/Ice/Connection.h +2 -2
  19. data/ext/ice/cpp/include/generated/Ice/ConnectionF.h +2 -2
  20. data/ext/ice/cpp/include/generated/Ice/Current.h +4 -4
  21. data/ext/ice/cpp/include/generated/Ice/Endpoint.h +2 -2
  22. data/ext/ice/cpp/include/generated/Ice/EndpointF.h +2 -2
  23. data/ext/ice/cpp/include/generated/Ice/EndpointTypes.h +2 -2
  24. data/ext/ice/cpp/include/generated/Ice/FacetMap.h +2 -2
  25. data/ext/ice/cpp/include/generated/Ice/Identity.h +2 -2
  26. data/ext/ice/cpp/include/generated/Ice/ImplicitContext.h +2 -2
  27. data/ext/ice/cpp/include/generated/Ice/ImplicitContextF.h +2 -2
  28. data/ext/ice/cpp/include/generated/Ice/Instrumentation.h +2 -2
  29. data/ext/ice/cpp/include/generated/Ice/InstrumentationF.h +2 -2
  30. data/ext/ice/cpp/include/generated/Ice/LocalException.h +2 -2
  31. data/ext/ice/cpp/include/generated/Ice/Locator.h +2 -2
  32. data/ext/ice/cpp/include/generated/Ice/LocatorF.h +2 -2
  33. data/ext/ice/cpp/include/generated/Ice/Logger.h +2 -2
  34. data/ext/ice/cpp/include/generated/Ice/LoggerF.h +2 -2
  35. data/ext/ice/cpp/include/generated/Ice/Metrics.h +2 -2
  36. data/ext/ice/cpp/include/generated/Ice/ObjectAdapter.h +2 -2
  37. data/ext/ice/cpp/include/generated/Ice/ObjectAdapterF.h +2 -2
  38. data/ext/ice/cpp/include/generated/Ice/ObjectFactory.h +2 -2
  39. data/ext/ice/cpp/include/generated/Ice/Plugin.h +2 -2
  40. data/ext/ice/cpp/include/generated/Ice/PluginF.h +2 -2
  41. data/ext/ice/cpp/include/generated/Ice/Process.h +2 -2
  42. data/ext/ice/cpp/include/generated/Ice/ProcessF.h +2 -2
  43. data/ext/ice/cpp/include/generated/Ice/Properties.h +8 -8
  44. data/ext/ice/cpp/include/generated/Ice/PropertiesAdmin.h +2 -2
  45. data/ext/ice/cpp/include/generated/Ice/PropertiesF.h +2 -2
  46. data/ext/ice/cpp/include/generated/Ice/RemoteLogger.h +2 -2
  47. data/ext/ice/cpp/include/generated/Ice/Router.h +2 -2
  48. data/ext/ice/cpp/include/generated/Ice/RouterF.h +2 -2
  49. data/ext/ice/cpp/include/generated/Ice/ServantLocator.h +2 -2
  50. data/ext/ice/cpp/include/generated/Ice/ServantLocatorF.h +2 -2
  51. data/ext/ice/cpp/include/generated/Ice/SliceChecksumDict.h +2 -2
  52. data/ext/ice/cpp/include/generated/Ice/ValueFactory.h +2 -2
  53. data/ext/ice/cpp/include/generated/Ice/Version.h +2 -2
  54. data/ext/ice/cpp/include/generated/IceSSL/ConnectionInfo.h +2 -2
  55. data/ext/ice/cpp/include/generated/IceSSL/ConnectionInfoF.h +2 -2
  56. data/ext/ice/cpp/include/generated/IceSSL/EndpointInfo.h +2 -2
  57. data/ext/ice/cpp/src/Ice/Acceptor.h +1 -1
  58. data/ext/ice/cpp/src/Ice/BuiltinSequences.cpp +2 -2
  59. data/ext/ice/cpp/src/Ice/Communicator.cpp +2 -2
  60. data/ext/ice/cpp/src/Ice/CommunicatorF.cpp +2 -2
  61. data/ext/ice/cpp/src/Ice/Connection.cpp +2 -2
  62. data/ext/ice/cpp/src/Ice/ConnectionF.cpp +2 -2
  63. data/ext/ice/cpp/src/Ice/ConnectionFactory.cpp +1 -1
  64. data/ext/ice/cpp/src/Ice/ConnectionFactory.h +2 -2
  65. data/ext/ice/cpp/src/Ice/ConnectionI.cpp +5 -5
  66. data/ext/ice/cpp/src/Ice/ConnectionI.h +6 -8
  67. data/ext/ice/cpp/src/Ice/CountDownLatch.cpp +0 -8
  68. data/ext/ice/cpp/src/Ice/Current.cpp +2 -2
  69. data/ext/ice/cpp/src/Ice/DefaultsAndOverrides.cpp +0 -2
  70. data/ext/ice/cpp/src/Ice/DynamicLibrary.cpp +2 -9
  71. data/ext/ice/cpp/src/Ice/Endpoint.cpp +2 -2
  72. data/ext/ice/cpp/src/Ice/EndpointF.cpp +2 -2
  73. data/ext/ice/cpp/src/Ice/EndpointTypes.cpp +2 -2
  74. data/ext/ice/cpp/src/Ice/EventHandler.cpp +1 -1
  75. data/ext/ice/cpp/src/Ice/EventHandler.h +2 -2
  76. data/ext/ice/cpp/src/Ice/Exception.cpp +0 -27
  77. data/ext/ice/cpp/src/Ice/FacetMap.cpp +2 -2
  78. data/ext/ice/cpp/src/Ice/IPEndpointI.cpp +0 -46
  79. data/ext/ice/cpp/src/Ice/IPEndpointI.h +1 -11
  80. data/ext/ice/cpp/src/Ice/Identity.cpp +2 -2
  81. data/ext/ice/cpp/src/Ice/ImplicitContext.cpp +2 -2
  82. data/ext/ice/cpp/src/Ice/ImplicitContextF.cpp +2 -2
  83. data/ext/ice/cpp/src/Ice/Instance.cpp +2 -6
  84. data/ext/ice/cpp/src/Ice/Instrumentation.cpp +2 -2
  85. data/ext/ice/cpp/src/Ice/InstrumentationF.cpp +2 -2
  86. data/ext/ice/cpp/src/Ice/LocalException.cpp +2 -2
  87. data/ext/ice/cpp/src/Ice/Locator.cpp +2 -2
  88. data/ext/ice/cpp/src/Ice/LocatorF.cpp +2 -2
  89. data/ext/ice/cpp/src/Ice/Logger.cpp +2 -2
  90. data/ext/ice/cpp/src/Ice/LoggerF.cpp +2 -2
  91. data/ext/ice/cpp/src/Ice/LoggerI.cpp +1 -3
  92. data/ext/ice/cpp/src/Ice/Metrics.cpp +2 -2
  93. data/ext/ice/cpp/src/Ice/Network.cpp +15 -841
  94. data/ext/ice/cpp/src/Ice/Network.h +4 -86
  95. data/ext/ice/cpp/src/Ice/NetworkF.h +0 -4
  96. data/ext/ice/cpp/src/Ice/NetworkProxy.cpp +0 -13
  97. data/ext/ice/cpp/src/Ice/ObjectAdapter.cpp +2 -2
  98. data/ext/ice/cpp/src/Ice/ObjectAdapterF.cpp +2 -2
  99. data/ext/ice/cpp/src/Ice/ObjectFactory.cpp +2 -2
  100. data/ext/ice/cpp/src/Ice/Plugin.cpp +2 -2
  101. data/ext/ice/cpp/src/Ice/PluginF.cpp +2 -2
  102. data/ext/ice/cpp/src/Ice/Process.cpp +2 -2
  103. data/ext/ice/cpp/src/Ice/ProcessF.cpp +2 -2
  104. data/ext/ice/cpp/src/Ice/Properties.cpp +2 -2
  105. data/ext/ice/cpp/src/Ice/PropertiesAdmin.cpp +2 -2
  106. data/ext/ice/cpp/src/Ice/PropertiesF.cpp +2 -2
  107. data/ext/ice/cpp/src/Ice/PropertiesI.cpp +4 -12
  108. data/ext/ice/cpp/src/Ice/RemoteLogger.cpp +2 -2
  109. data/ext/ice/cpp/src/Ice/Router.cpp +2 -2
  110. data/ext/ice/cpp/src/Ice/RouterF.cpp +2 -2
  111. data/ext/ice/cpp/src/Ice/SHA1.cpp +27 -43
  112. data/ext/ice/cpp/src/Ice/Selector.cpp +1 -13
  113. data/ext/ice/cpp/src/Ice/Selector.h +1 -17
  114. data/ext/ice/cpp/src/Ice/ServantLocator.cpp +2 -2
  115. data/ext/ice/cpp/src/Ice/ServantLocatorF.cpp +2 -2
  116. data/ext/ice/cpp/src/Ice/SliceChecksumDict.cpp +2 -2
  117. data/ext/ice/cpp/src/Ice/StreamSocket.cpp +4 -167
  118. data/ext/ice/cpp/src/Ice/StreamSocket.h +3 -10
  119. data/ext/ice/cpp/src/Ice/TcpAcceptor.cpp +0 -121
  120. data/ext/ice/cpp/src/Ice/TcpAcceptor.h +2 -10
  121. data/ext/ice/cpp/src/Ice/TcpTransceiver.cpp +1 -1
  122. data/ext/ice/cpp/src/Ice/TcpTransceiver.h +1 -1
  123. data/ext/ice/cpp/src/Ice/Thread.cpp +1 -243
  124. data/ext/ice/cpp/src/Ice/ThreadPool.cpp +15 -51
  125. data/ext/ice/cpp/src/Ice/ThreadPool.h +6 -6
  126. data/ext/ice/cpp/src/Ice/Transceiver.h +1 -1
  127. data/ext/ice/cpp/src/Ice/UdpConnector.cpp +0 -5
  128. data/ext/ice/cpp/src/Ice/UdpTransceiver.cpp +13 -360
  129. data/ext/ice/cpp/src/Ice/UdpTransceiver.h +2 -23
  130. data/ext/ice/cpp/src/Ice/ValueFactory.cpp +2 -2
  131. data/ext/ice/cpp/src/Ice/Version.cpp +2 -2
  132. data/ext/ice/cpp/src/Ice/WSAcceptor.cpp +2 -2
  133. data/ext/ice/cpp/src/Ice/WSAcceptor.h +2 -2
  134. data/ext/ice/cpp/src/Ice/WSTransceiver.cpp +2 -45
  135. data/ext/ice/cpp/src/Ice/WSTransceiver.h +2 -2
  136. data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.cpp +2 -2
  137. data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.h +2 -2
  138. data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.cpp +2 -2
  139. data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.h +2 -2
  140. data/ext/ice/cpp/src/IceSSL/AcceptorI.cpp +2 -2
  141. data/ext/ice/cpp/src/IceSSL/AcceptorI.h +2 -2
  142. data/ext/ice/cpp/src/IceSSL/ConnectionInfo.cpp +2 -2
  143. data/ext/ice/cpp/src/IceSSL/ConnectionInfoF.cpp +2 -2
  144. data/ext/ice/cpp/src/IceSSL/EndpointInfo.cpp +2 -2
  145. data/ext/ice/cpp/src/IceSSL/Util.cpp +1 -1
  146. data/ext/ice/cpp/src/IceUtil/ConsoleUtil.cpp +1 -1
  147. data/ext/ice/cpp/src/IceUtil/FileUtil.cpp +4 -17
  148. data/ext/ice/cpp/src/IceUtil/RecMutex.cpp +0 -4
  149. data/ext/ice/cpp/src/IceUtil/StringUtil.cpp +0 -45
  150. data/ext/ice/cpp/src/IceUtil/UUID.cpp +2 -6
  151. data/ext/ice/cpp/src/IceUtil/UtilException.cpp +1 -1
  152. data/ext/ice/cpp/src/Slice/JavaUtil.cpp +22 -0
  153. data/ext/ice/cpp/src/Slice/JavaUtil.h +9 -0
  154. data/ext/ice/mcpp/system.c +0 -4
  155. data/ice.gemspec +1 -1
  156. data/lib/Glacier2/Metrics.rb +1 -1
  157. data/lib/Glacier2/PermissionsVerifier.rb +1 -1
  158. data/lib/Glacier2/PermissionsVerifierF.rb +1 -1
  159. data/lib/Glacier2/Router.rb +1 -1
  160. data/lib/Glacier2/RouterF.rb +1 -1
  161. data/lib/Glacier2/SSLInfo.rb +1 -1
  162. data/lib/Glacier2/Session.rb +1 -1
  163. data/lib/Ice/BuiltinSequences.rb +1 -1
  164. data/lib/Ice/Communicator.rb +1 -1
  165. data/lib/Ice/CommunicatorF.rb +1 -1
  166. data/lib/Ice/Connection.rb +1 -1
  167. data/lib/Ice/ConnectionF.rb +1 -1
  168. data/lib/Ice/Current.rb +1 -1
  169. data/lib/Ice/Endpoint.rb +1 -1
  170. data/lib/Ice/EndpointF.rb +1 -1
  171. data/lib/Ice/EndpointTypes.rb +1 -1
  172. data/lib/Ice/FacetMap.rb +1 -1
  173. data/lib/Ice/Identity.rb +1 -1
  174. data/lib/Ice/ImplicitContext.rb +1 -1
  175. data/lib/Ice/ImplicitContextF.rb +1 -1
  176. data/lib/Ice/Instrumentation.rb +1 -1
  177. data/lib/Ice/InstrumentationF.rb +1 -1
  178. data/lib/Ice/LocalException.rb +1 -1
  179. data/lib/Ice/Locator.rb +1 -1
  180. data/lib/Ice/LocatorF.rb +1 -1
  181. data/lib/Ice/Logger.rb +1 -1
  182. data/lib/Ice/LoggerF.rb +1 -1
  183. data/lib/Ice/Metrics.rb +1 -1
  184. data/lib/Ice/ObjectAdapter.rb +1 -1
  185. data/lib/Ice/ObjectAdapterF.rb +1 -1
  186. data/lib/Ice/ObjectFactory.rb +1 -1
  187. data/lib/Ice/Plugin.rb +1 -1
  188. data/lib/Ice/PluginF.rb +1 -1
  189. data/lib/Ice/Process.rb +1 -1
  190. data/lib/Ice/ProcessF.rb +1 -1
  191. data/lib/Ice/Properties.rb +1 -1
  192. data/lib/Ice/PropertiesAdmin.rb +1 -1
  193. data/lib/Ice/PropertiesF.rb +1 -1
  194. data/lib/Ice/RemoteLogger.rb +1 -1
  195. data/lib/Ice/Router.rb +1 -1
  196. data/lib/Ice/RouterF.rb +1 -1
  197. data/lib/Ice/ServantLocator.rb +1 -1
  198. data/lib/Ice/ServantLocatorF.rb +1 -1
  199. data/lib/Ice/SliceChecksumDict.rb +1 -1
  200. data/lib/Ice/ValueFactory.rb +1 -1
  201. data/lib/Ice/Version.rb +1 -1
  202. data/lib/IceBox/IceBox.rb +1 -1
  203. data/lib/IceGrid/Admin.rb +1 -1
  204. data/lib/IceGrid/Descriptor.rb +1 -1
  205. data/lib/IceGrid/Exception.rb +1 -1
  206. data/lib/IceGrid/FileParser.rb +1 -1
  207. data/lib/IceGrid/PluginFacade.rb +1 -1
  208. data/lib/IceGrid/Registry.rb +1 -1
  209. data/lib/IceGrid/Session.rb +1 -1
  210. data/lib/IceGrid/UserAccountMapper.rb +1 -1
  211. data/lib/IcePatch2/FileInfo.rb +1 -1
  212. data/lib/IcePatch2/FileServer.rb +1 -1
  213. data/lib/IceStorm/IceStorm.rb +1 -1
  214. data/lib/IceStorm/Metrics.rb +1 -1
  215. data/slice/Ice/Current.ice +1 -1
  216. data/slice/Ice/Properties.ice +3 -3
  217. metadata +3 -3
@@ -30,9 +30,7 @@
30
30
  # pragma warning(disable:4244) // 'argument': conversion from 'int' to 'u_short', possible loss of data
31
31
  #endif
32
32
 
33
- #if defined(ICE_OS_UWP)
34
- # include <IceUtil/InputUtil.h>
35
- #elif defined(_WIN32)
33
+ #if defined(_WIN32)
36
34
  # include <winsock2.h>
37
35
  # include <ws2tcpip.h>
38
36
  # ifdef __MINGW32__
@@ -56,12 +54,6 @@
56
54
  # pragma GCC diagnostic ignored "-Wmissing-field-initializers"
57
55
  #endif
58
56
 
59
- #if defined(_WIN32)
60
- # ifndef SIO_LOOPBACK_FAST_PATH
61
- # define SIO_LOOPBACK_FAST_PATH _WSAIOW(IOC_VENDOR,16)
62
- # endif
63
- #endif
64
-
65
57
  #if defined(__MINGW32__)
66
58
  //
67
59
  // Work-around for missing definitions in MinGW Windows headers
@@ -80,17 +72,6 @@ using namespace std;
80
72
  using namespace Ice;
81
73
  using namespace IceInternal;
82
74
 
83
- #ifdef ICE_OS_UWP
84
- using namespace Concurrency;
85
- using namespace Platform;
86
- using namespace Windows::Foundation;
87
- using namespace Windows::Foundation::Collections;
88
- using namespace Windows::Storage::Streams;
89
- using namespace Windows::Networking;
90
- using namespace Windows::Networking::Sockets;
91
- using namespace Windows::Networking::Connectivity;
92
- #endif
93
-
94
75
  #ifdef _WIN32
95
76
  int
96
77
  IceInternal::getSystemErrno()
@@ -119,9 +100,7 @@ public:
119
100
  }
120
101
  };
121
102
 
122
- #ifndef ICE_OS_UWP
123
-
124
- # ifndef ICE_CPP11_COMPILER
103
+ #ifndef ICE_CPP11_COMPILER
125
104
 
126
105
  struct AddressIsIPv6 : public unary_function<Address, bool>
127
106
  {
@@ -133,7 +112,7 @@ public:
133
112
  return ss.saStorage.ss_family == AF_INET6;
134
113
  }
135
114
  };
136
- # endif
115
+ #endif
137
116
 
138
117
  void
139
118
  sortAddresses(vector<Address>& addrs, ProtocolSupport protocol, Ice::EndpointSelectionType selType, bool preferIPv6)
@@ -196,47 +175,7 @@ setKeepAlive(SOCKET fd)
196
175
  throw SocketException(__FILE__, __LINE__, getSocketErrno());
197
176
  }
198
177
  }
199
- #endif
200
178
 
201
- #if defined(_WIN32) && !defined(ICE_OS_UWP)
202
- void
203
- setTcpLoopbackFastPath(SOCKET fd)
204
- {
205
- int OptionValue = 1;
206
- DWORD NumberOfBytesReturned = 0;
207
-
208
- int status =
209
- WSAIoctl(fd, SIO_LOOPBACK_FAST_PATH, &OptionValue, sizeof(OptionValue), ICE_NULLPTR, 0, &NumberOfBytesReturned, 0, 0);
210
- if(status == SOCKET_ERROR)
211
- {
212
- // On platforms that do not support fast path (< Windows 8), WSAEONOTSUPP is expected.
213
- DWORD LastError = ::GetLastError();
214
- if(LastError != WSAEOPNOTSUPP)
215
- {
216
- closeSocketNoThrow(fd);
217
- throw SocketException(__FILE__, __LINE__, getSocketErrno());
218
- }
219
- }
220
- }
221
- #endif
222
-
223
- #ifdef ICE_OS_UWP
224
- SOCKET
225
- createSocketImpl(bool udp, int)
226
- {
227
- if(udp)
228
- {
229
- return ref new DatagramSocket();
230
- }
231
- else
232
- {
233
- StreamSocket^ socket = ref new StreamSocket();
234
- socket->Control->KeepAlive = true;
235
- socket->Control->NoDelay = true;
236
- return socket;
237
- }
238
- }
239
- #else
240
179
  SOCKET
241
180
  createSocketImpl(bool udp, int family)
242
181
  {
@@ -259,25 +198,11 @@ createSocketImpl(bool udp, int family)
259
198
  {
260
199
  setTcpNoDelay(fd);
261
200
  setKeepAlive(fd);
262
-
263
- #if defined(_WIN32) && !defined(ICE_OS_UWP)
264
- //
265
- // FIX: the fast path loopback appears to cause issues with
266
- // connection closure when it's enabled. Sometime, a peer
267
- // doesn't receive the TCP/IP connection closure (RST) from
268
- // the other peer and it ends up hanging. This is showing up
269
- // with the background test when ran with WS. The test
270
- // sporadically hangs on exit. See bug #6093.
271
- //
272
- //setTcpLoopbackFastPath(fd);
273
- #endif
274
201
  }
275
202
 
276
203
  return fd;
277
204
  }
278
- #endif
279
205
 
280
- #ifndef ICE_OS_UWP
281
206
  vector<Address>
282
207
  getLocalAddresses(ProtocolSupport protocol, bool includeLoopback, bool singleAddressPerInterface)
283
208
  {
@@ -852,8 +777,6 @@ getLoopbackAddresses(ProtocolSupport protocol, int port = 0)
852
777
  return result;
853
778
  }
854
779
 
855
- #endif // #ifndef ICE_OS_UWP
856
-
857
780
  }
858
781
 
859
782
  ReadyCallback::~ReadyCallback()
@@ -896,154 +819,6 @@ IceInternal::NativeInfo::completed(SocketOperation operation)
896
819
  }
897
820
  }
898
821
 
899
- #elif defined(ICE_OS_UWP)
900
-
901
- void
902
- IceInternal::NativeInfo::queueAction(SocketOperation op, IAsyncAction^ action, bool connect)
903
- {
904
- AsyncInfo* asyncInfo = getAsyncInfo(op);
905
- if(checkIfErrorOrCompleted(op, action, action->Status, connect))
906
- {
907
- asyncInfo->count = 0;
908
- asyncInfo->error = ERROR_SUCCESS;
909
- }
910
- else
911
- {
912
- action->Completed = ref new AsyncActionCompletedHandler(
913
- [=] (IAsyncAction^ info, Windows::Foundation::AsyncStatus status)
914
- {
915
- //
916
- // COMPILERFIX with v141 using operator!= and operator== inside
917
- // a lambda callback triggers a compiler bug, we move the code to
918
- // a seperate private method to workaround the issue.
919
- //
920
- this->queueActionCompleted(op, asyncInfo, info, status);
921
- });
922
- asyncInfo->operation = action;
923
- }
924
- }
925
-
926
- void
927
- IceInternal::NativeInfo::queueActionCompleted(SocketOperation op, AsyncInfo* asyncInfo, IAsyncAction^ info,
928
- Windows::Foundation::AsyncStatus status)
929
- {
930
- if(status != Windows::Foundation::AsyncStatus::Completed)
931
- {
932
- asyncInfo->error = info->ErrorCode.Value;
933
- }
934
- else
935
- {
936
- asyncInfo->error = ERROR_SUCCESS;
937
- }
938
- asyncInfo->count = 0;
939
- completed(op);
940
- }
941
-
942
- void
943
- IceInternal::NativeInfo::queueOperation(SocketOperation op, IAsyncOperation<unsigned int>^ operation)
944
- {
945
- AsyncInfo* info = getAsyncInfo(op);
946
- Windows::Foundation::AsyncStatus status = operation->Status;
947
- if(status == Windows::Foundation::AsyncStatus::Completed)
948
- {
949
- //
950
- // NOTE: it's important to modify the count _before_ calling the completion handler
951
- // since this might not always be called with the connection mutex but from a Windows
952
- // thread pool thread if we chained multiple Async calls (GetGetOutputStreamAsync and
953
- // StoreAsync for example, see the UDPTransceiver implementation). So we can't modify
954
- // the AsyncInfo structure after calling the completed callback.
955
- //
956
- info->count = static_cast<int>(operation->GetResults());
957
- info->error = ERROR_SUCCESS;
958
- _completedHandler(op);
959
- return;
960
- }
961
- else if(!checkIfErrorOrCompleted(op, operation, status))
962
- {
963
- if(!info->completedHandler)
964
- {
965
- info->completedHandler = ref new AsyncOperationCompletedHandler<unsigned int>(
966
- [=] (IAsyncOperation<unsigned int>^ operation, Windows::Foundation::AsyncStatus status)
967
- {
968
- //
969
- // COMPILERFIX with v141 using operator!= and operator== inside
970
- // a lambda callback triggers a compiler bug, we move the code to
971
- // a seperate private method to workaround the issue.
972
- //
973
- this->queueOperationCompleted(op, info, operation, status);
974
- });
975
- }
976
- operation->Completed = info->completedHandler;
977
- info->operation = operation;
978
- }
979
- }
980
-
981
- void
982
- IceInternal::NativeInfo::queueOperationCompleted(SocketOperation op, AsyncInfo* info,
983
- IAsyncOperation<unsigned int>^ operation,
984
- Windows::Foundation::AsyncStatus status)
985
- {
986
- if(status != Windows::Foundation::AsyncStatus::Completed)
987
- {
988
- info->count = 0;
989
- info->error = operation->ErrorCode.Value;
990
- }
991
- else
992
- {
993
- info->count = static_cast<int>(operation->GetResults());
994
- info->error = ERROR_SUCCESS;
995
- }
996
- completed(op);
997
- }
998
-
999
- void
1000
- IceInternal::NativeInfo::setCompletedHandler(SocketOperationCompletedHandler^ handler)
1001
- {
1002
- _completedHandler = handler;
1003
- }
1004
-
1005
- void
1006
- IceInternal::NativeInfo::completed(SocketOperation operation)
1007
- {
1008
- assert(_completedHandler);
1009
- _completedHandler(operation);
1010
- }
1011
-
1012
- bool
1013
- IceInternal::NativeInfo::checkIfErrorOrCompleted(SocketOperation op, IAsyncInfo^ info, Windows::Foundation::AsyncStatus status, bool connect)
1014
- {
1015
- //
1016
- // NOTE: It's important to only check for info->Status once as it
1017
- // might change during the checks below (the Status can be changed
1018
- // by the Windows thread pool concurrently).
1019
- //
1020
- // We consider that a canceled async status is the same as an
1021
- // error. A canceled async status can occur if there's a timeout
1022
- // and the socket is closed.
1023
- //
1024
- if(status == Windows::Foundation::AsyncStatus::Completed)
1025
- {
1026
- _completedHandler(op);
1027
- return true;
1028
- }
1029
- else if (status == Windows::Foundation::AsyncStatus::Started)
1030
- {
1031
- return false;
1032
- }
1033
- else
1034
- {
1035
- if(connect) // Connect
1036
- {
1037
- checkConnectErrorCode(__FILE__, __LINE__, info->ErrorCode.Value);
1038
- }
1039
- else
1040
- {
1041
- checkErrorCode(__FILE__, __LINE__, info->ErrorCode.Value);
1042
- }
1043
- return true; // Prevent compiler warning.
1044
- }
1045
- }
1046
-
1047
822
  #else
1048
823
 
1049
824
  void
@@ -1070,72 +845,23 @@ IceInternal::NativeInfo::newFd()
1070
845
  bool
1071
846
  IceInternal::noMoreFds(int error)
1072
847
  {
1073
- #if defined(ICE_OS_UWP)
1074
- return error == (int)SocketErrorStatus::TooManyOpenFiles;
1075
- #elif defined(_WIN32)
848
+ #if defined(_WIN32)
1076
849
  return error == WSAEMFILE;
1077
850
  #else
1078
851
  return error == EMFILE || error == ENFILE;
1079
852
  #endif
1080
853
  }
1081
854
 
1082
- #if defined(ICE_OS_UWP)
1083
- string
1084
- IceInternal::errorToStringDNS(int)
1085
- {
1086
- return "Host not found";
1087
- }
1088
- #else
1089
855
  string
1090
856
  IceInternal::errorToStringDNS(int error)
1091
857
  {
1092
- # if defined(_WIN32)
858
+ #if defined(_WIN32)
1093
859
  return IceUtilInternal::errorToString(error);
1094
- # else
860
+ #else
1095
861
  return gai_strerror(error);
1096
- # endif
1097
- }
1098
862
  #endif
1099
-
1100
- #ifdef ICE_OS_UWP
1101
- vector<Address>
1102
- IceInternal::getAddresses(const string& host, int port, ProtocolSupport, Ice::EndpointSelectionType, bool, bool)
1103
- {
1104
- try
1105
- {
1106
- vector<Address> result;
1107
- Address addr;
1108
- if(host.empty())
1109
- {
1110
- addr.host = ref new HostName("localhost");
1111
- }
1112
- else
1113
- {
1114
- //
1115
- // Don't need to pass a wide string converter as the wide string is passed
1116
- // to Windows API.
1117
- //
1118
- addr.host = ref new HostName(ref new String(
1119
- stringToWstring(host,
1120
- getProcessStringConverter()).c_str()));
1121
- }
1122
- stringstream os;
1123
- os << port;
1124
- //
1125
- // Don't need to use any string converter here as the port number use just
1126
- // ASCII characters.
1127
- //
1128
- addr.port = ref new String(stringToWstring(os.str()).c_str());
1129
- result.push_back(addr);
1130
- return result;
1131
- }
1132
- catch(Platform::Exception^ pex)
1133
- {
1134
- throw DNSException(__FILE__, __LINE__, (int)SocketError::GetStatus(pex->HResult), host);
1135
- }
1136
-
1137
863
  }
1138
- #else
864
+
1139
865
  vector<Address>
1140
866
  IceInternal::getAddresses(const string& host, int port, ProtocolSupport protocol, Ice::EndpointSelectionType selType,
1141
867
  bool preferIPv6, bool canBlock)
@@ -1189,11 +915,11 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport protocol
1189
915
  // AI_NUMERICHOST is specified and the host name is not a IP
1190
916
  // address. However on some platforms (e.g. macOS 10.4.x)
1191
917
  // EAI_NODATA is also returned so we also check for it.
1192
- # ifdef EAI_NODATA
918
+ #ifdef EAI_NODATA
1193
919
  if(!canBlock && (rs == EAI_NONAME || rs == EAI_NODATA))
1194
- # else
920
+ #else
1195
921
  if(!canBlock && rs == EAI_NONAME)
1196
- # endif
922
+ #endif
1197
923
  {
1198
924
  return result; // Empty result indicates that a canBlock lookup is necessary.
1199
925
  }
@@ -1238,22 +964,12 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport protocol
1238
964
  sortAddresses(result, protocol, selType, preferIPv6);
1239
965
  return result;
1240
966
  }
1241
- #endif
1242
967
 
1243
- #ifdef ICE_OS_UWP
1244
- ProtocolSupport
1245
- IceInternal::getProtocolSupport(const Address&)
1246
- {
1247
- // For UWP, there's no distinction between IPv4 and IPv6 adresses.
1248
- return EnableBoth;
1249
- }
1250
- #else
1251
968
  ProtocolSupport
1252
969
  IceInternal::getProtocolSupport(const Address& addr)
1253
970
  {
1254
971
  return addr.saStorage.ss_family == AF_INET ? EnableIPv4 : EnableIPv6;
1255
972
  }
1256
- #endif
1257
973
 
1258
974
  Address
1259
975
  IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport protocol, bool preferIPv6, bool canBlock)
@@ -1265,16 +981,6 @@ IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport p
1265
981
  if(host.empty())
1266
982
  {
1267
983
  Address addr;
1268
- #ifdef ICE_OS_UWP
1269
- ostringstream os;
1270
- os << port;
1271
- //
1272
- // Don't need to use any string converter here as the port number use just
1273
- // ASCII characters.
1274
- //
1275
- addr.port = ref new String(stringToWstring(os.str()).c_str());
1276
- addr.host = nullptr; // Equivalent of inaddr_any, see doBind implementation.
1277
- #else
1278
984
  memset(&addr.saStorage, 0, sizeof(sockaddr_storage));
1279
985
  if(protocol != EnableIPv4)
1280
986
  {
@@ -1288,7 +994,6 @@ IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport p
1288
994
  addr.saIn.sin_port = htons(port);
1289
995
  addr.saIn.sin_addr.s_addr = htonl(INADDR_ANY);
1290
996
  }
1291
- #endif
1292
997
  return addr;
1293
998
  }
1294
999
  vector<Address> addrs = getAddresses(host, port, protocol, Ice::ICE_ENUM(EndpointSelectionType, Ordered),
@@ -1299,26 +1004,6 @@ IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport p
1299
1004
  int
1300
1005
  IceInternal::compareAddress(const Address& addr1, const Address& addr2)
1301
1006
  {
1302
- #ifdef ICE_OS_UWP
1303
- int o = String::CompareOrdinal(addr1.port, addr2.port);
1304
- if(o != 0)
1305
- {
1306
- return o;
1307
- }
1308
- if(addr1.host == addr2.host)
1309
- {
1310
- return 0;
1311
- }
1312
- if(addr1.host == nullptr)
1313
- {
1314
- return -1;
1315
- }
1316
- if(addr2.host == nullptr)
1317
- {
1318
- return 1;
1319
- }
1320
- return String::CompareOrdinal(addr1.host->RawName, addr2.host->RawName);
1321
- #else
1322
1007
  if(addr1.saStorage.ss_family < addr2.saStorage.ss_family)
1323
1008
  {
1324
1009
  return -1;
@@ -1371,16 +1056,8 @@ IceInternal::compareAddress(const Address& addr1, const Address& addr2)
1371
1056
  }
1372
1057
 
1373
1058
  return 0;
1374
- #endif
1375
1059
  }
1376
1060
 
1377
- #ifdef ICE_OS_UWP
1378
- bool
1379
- IceInternal::isIPv6Supported()
1380
- {
1381
- return true;
1382
- }
1383
- #else
1384
1061
  bool
1385
1062
  IceInternal::isIPv6Supported()
1386
1063
  {
@@ -1395,23 +1072,12 @@ IceInternal::isIPv6Supported()
1395
1072
  return true;
1396
1073
  }
1397
1074
  }
1398
- #endif
1399
1075
 
1400
- #ifdef ICE_OS_UWP
1401
- SOCKET
1402
- IceInternal::createSocket(bool udp, const Address&)
1403
- {
1404
- return createSocketImpl(udp, 0);
1405
- }
1406
- #else
1407
1076
  SOCKET
1408
1077
  IceInternal::createSocket(bool udp, const Address& addr)
1409
1078
  {
1410
1079
  return createSocketImpl(udp, addr.saStorage.ss_family);
1411
1080
  }
1412
- #endif
1413
-
1414
- #ifndef ICE_OS_UWP
1415
1081
  SOCKET
1416
1082
  IceInternal::createServerSocket(bool udp, const Address& addr, ProtocolSupport protocol)
1417
1083
  {
@@ -1433,27 +1099,11 @@ IceInternal::createServerSocket(bool udp, const Address& addr, ProtocolSupport p
1433
1099
  }
1434
1100
  return fd;
1435
1101
  }
1436
- #else
1437
- SOCKET
1438
- IceInternal::createServerSocket(bool udp, const Address& addr, ProtocolSupport)
1439
- {
1440
- return createSocket(udp, addr);
1441
- }
1442
- #endif
1443
1102
 
1444
1103
  void
1445
1104
  IceInternal::closeSocketNoThrow(SOCKET fd)
1446
1105
  {
1447
- #if defined(ICE_OS_UWP)
1448
- //
1449
- // NOTE: StreamSocket::Close or DatagramSocket::Close aren't
1450
- // exposed in C++, you have to delete the socket to close
1451
- // it. According some Microsoft samples, this is safe even if
1452
- // there are still references to the object...
1453
- //
1454
- //fd->Close();
1455
- delete fd;
1456
- #elif defined(_WIN32)
1106
+ #if defined(_WIN32)
1457
1107
  int error = WSAGetLastError();
1458
1108
  closesocket(fd);
1459
1109
  WSASetLastError(error);
@@ -1467,16 +1117,7 @@ IceInternal::closeSocketNoThrow(SOCKET fd)
1467
1117
  void
1468
1118
  IceInternal::closeSocket(SOCKET fd)
1469
1119
  {
1470
- #if defined(ICE_OS_UWP)
1471
- //
1472
- // NOTE: StreamSocket::Close or DatagramSocket::Close aren't
1473
- // exposed in C++, you have to delete the socket to close
1474
- // it. According some Microsoft samples, this is safe even if
1475
- // there are still references to the object...
1476
- //
1477
- //fd->Close();
1478
- delete fd;
1479
- #elif defined(_WIN32)
1120
+ #if defined(_WIN32)
1480
1121
  int error = WSAGetLastError();
1481
1122
  if(closesocket(fd) == SOCKET_ERROR)
1482
1123
  {
@@ -1514,32 +1155,16 @@ IceInternal::addrToString(const Address& addr)
1514
1155
  void
1515
1156
  IceInternal::fdToLocalAddress(SOCKET fd, Address& addr)
1516
1157
  {
1517
- #ifndef ICE_OS_UWP
1518
1158
  socklen_t len = static_cast<socklen_t>(sizeof(sockaddr_storage));
1519
1159
  if(getsockname(fd, &addr.sa, &len) == SOCKET_ERROR)
1520
1160
  {
1521
1161
  throw SocketException(__FILE__, __LINE__, getSocketErrno());
1522
1162
  }
1523
- #else
1524
- StreamSocket^ stream = dynamic_cast<StreamSocket^>(fd);
1525
- if(stream)
1526
- {
1527
- addr.host = stream->Information->LocalAddress;
1528
- addr.port = stream->Information->LocalPort;
1529
- }
1530
- DatagramSocket^ datagram = dynamic_cast<DatagramSocket^>(fd);
1531
- if(datagram)
1532
- {
1533
- addr.host = datagram->Information->LocalAddress;
1534
- addr.port = datagram->Information->LocalPort;
1535
- }
1536
- #endif
1537
1163
  }
1538
1164
 
1539
1165
  bool
1540
1166
  IceInternal::fdToRemoteAddress(SOCKET fd, Address& addr)
1541
1167
  {
1542
- #ifndef ICE_OS_UWP
1543
1168
  socklen_t len = static_cast<socklen_t>(sizeof(sockaddr_storage));
1544
1169
  if(getpeername(fd, &addr.sa, &len) == SOCKET_ERROR)
1545
1170
  {
@@ -1552,23 +1177,7 @@ IceInternal::fdToRemoteAddress(SOCKET fd, Address& addr)
1552
1177
  throw SocketException(__FILE__, __LINE__, getSocketErrno());
1553
1178
  }
1554
1179
  }
1555
-
1556
1180
  return true;
1557
- #else
1558
- StreamSocket^ stream = dynamic_cast<StreamSocket^>(fd);
1559
- if(stream != nullptr)
1560
- {
1561
- addr.host = stream->Information->RemoteAddress;
1562
- addr.port = stream->Information->RemotePort;
1563
- }
1564
- DatagramSocket^ datagram = dynamic_cast<DatagramSocket^>(fd);
1565
- if(datagram != nullptr)
1566
- {
1567
- addr.host = datagram->Information->RemoteAddress;
1568
- addr.port = datagram->Information->RemotePort;
1569
- }
1570
- return addr.host != nullptr;
1571
- #endif
1572
1181
  }
1573
1182
 
1574
1183
  std::string
@@ -1692,69 +1301,9 @@ IceInternal::addressesToString(const Address& localAddr, const Address& remoteAd
1692
1301
  bool
1693
1302
  IceInternal::isAddressValid(const Address& addr)
1694
1303
  {
1695
- #ifndef ICE_OS_UWP
1696
1304
  return addr.saStorage.ss_family != AF_UNSPEC;
1697
- #else
1698
- return addr.host != nullptr || addr.port != nullptr;
1699
- #endif
1700
1305
  }
1701
1306
 
1702
- #ifdef ICE_OS_UWP
1703
- vector<string>
1704
- IceInternal::getHostsForEndpointExpand(const string& host, ProtocolSupport protocolSupport, bool includeLoopback)
1705
- {
1706
- vector<string> hosts;
1707
- if(host.empty() || host == "0.0.0.0" || host == "::" || host == "0:0:0:0:0:0:0:0")
1708
- {
1709
- for(IIterator<HostName^>^ it = NetworkInformation::GetHostNames()->First(); it->HasCurrent; it->MoveNext())
1710
- {
1711
- HostName^ h = it->Current;
1712
- if(h->IPInformation != nullptr && h->IPInformation->NetworkAdapter != nullptr)
1713
- {
1714
- hosts.push_back(wstringToString(h->CanonicalName->Data(), getProcessStringConverter()));
1715
- }
1716
- }
1717
- if(hosts.empty() || includeLoopback)
1718
- {
1719
- if(protocolSupport != EnableIPv6)
1720
- {
1721
- hosts.push_back("127.0.0.1");
1722
- }
1723
- if(protocolSupport != EnableIPv4)
1724
- {
1725
- hosts.push_back("::1");
1726
- }
1727
- }
1728
- }
1729
- return hosts;
1730
- }
1731
-
1732
- vector<string>
1733
- IceInternal::getInterfacesForMulticast(const string& intf, ProtocolSupport)
1734
- {
1735
- vector<string> interfaces;
1736
- if(intf.empty() || intf == "0.0.0.0" || intf == "::" || intf == "0:0:0:0:0:0:0:0")
1737
- {
1738
- for(IIterator<HostName^>^ it = NetworkInformation::GetHostNames()->First(); it->HasCurrent; it->MoveNext())
1739
- {
1740
- HostName^ h = it->Current;
1741
- if(h->IPInformation != nullptr && h->IPInformation->NetworkAdapter != nullptr)
1742
- {
1743
- string s = wstringToString(h->CanonicalName->Data(), getProcessStringConverter());
1744
- if(find(interfaces.begin(), interfaces.end(), s) == interfaces.end())
1745
- {
1746
- interfaces.push_back(s);
1747
- }
1748
- }
1749
- }
1750
- }
1751
- if(interfaces.empty())
1752
- {
1753
- interfaces.push_back(intf);
1754
- }
1755
- return interfaces;
1756
- }
1757
- #else
1758
1307
  vector<string>
1759
1308
  IceInternal::getHostsForEndpointExpand(const string& host, ProtocolSupport protocolSupport, bool includeLoopback)
1760
1309
  {
@@ -1807,12 +1356,10 @@ IceInternal::getInterfacesForMulticast(const string& intf, ProtocolSupport proto
1807
1356
  }
1808
1357
  return interfaces;
1809
1358
  }
1810
- #endif
1811
1359
 
1812
1360
  string
1813
1361
  IceInternal::inetAddrToString(const Address& ss)
1814
1362
  {
1815
- #ifndef ICE_OS_UWP
1816
1363
  int size = getAddressStorageSize(ss);
1817
1364
  if(size == 0)
1818
1365
  {
@@ -1824,26 +1371,11 @@ IceInternal::inetAddrToString(const Address& ss)
1824
1371
  getnameinfo(&ss.sa, static_cast<socklen_t>(size), namebuf, static_cast<socklen_t>(sizeof(namebuf)), 0, 0,
1825
1372
  NI_NUMERICHOST);
1826
1373
  return string(namebuf);
1827
- #else
1828
- if(ss.host == nullptr)
1829
- {
1830
- return "";
1831
- }
1832
- else
1833
- {
1834
- //
1835
- // Don't need to pass a wide string converter as the wide string come
1836
- // from Windows API.
1837
- //
1838
- return wstringToString(ss.host->RawName->Data(), getProcessStringConverter());
1839
- }
1840
- #endif
1841
1374
  }
1842
1375
 
1843
1376
  int
1844
1377
  IceInternal::getPort(const Address& addr)
1845
1378
  {
1846
- #ifndef ICE_OS_UWP
1847
1379
  if(addr.saStorage.ss_family == AF_INET)
1848
1380
  {
1849
1381
  return ntohs(addr.saIn.sin_port);
@@ -1856,23 +1388,11 @@ IceInternal::getPort(const Address& addr)
1856
1388
  {
1857
1389
  return -1;
1858
1390
  }
1859
- #else
1860
- IceUtil::Int64 port = 0;
1861
- //
1862
- // Don't need to use any string converter here as the port number use just ASCII characters.
1863
- //
1864
- if(addr.port == nullptr || !IceUtilInternal::stringToInt64(wstringToString(addr.port->Data()), port))
1865
- {
1866
- return -1;
1867
- }
1868
- return static_cast<int>(port);
1869
- #endif
1870
1391
  }
1871
1392
 
1872
1393
  void
1873
1394
  IceInternal::setPort(Address& addr, int port)
1874
1395
  {
1875
- #ifndef ICE_OS_UWP
1876
1396
  if(addr.saStorage.ss_family == AF_INET)
1877
1397
  {
1878
1398
  addr.saIn.sin_port = htons(port);
@@ -1882,21 +1402,11 @@ IceInternal::setPort(Address& addr, int port)
1882
1402
  assert(addr.saStorage.ss_family == AF_INET6);
1883
1403
  addr.saIn6.sin6_port = htons(port);
1884
1404
  }
1885
- #else
1886
- ostringstream os;
1887
- os << port;
1888
- //
1889
- // Don't need to use any string converter here as the port number use just
1890
- // ASCII characters.
1891
- //
1892
- addr.port = ref new String(stringToWstring(os.str()).c_str());
1893
- #endif
1894
1405
  }
1895
1406
 
1896
1407
  bool
1897
1408
  IceInternal::isMulticast(const Address& addr)
1898
1409
  {
1899
- #ifndef ICE_OS_UWP
1900
1410
  if(addr.saStorage.ss_family == AF_INET)
1901
1411
  {
1902
1412
  return IN_MULTICAST(ntohl(addr.saIn.sin_addr.s_addr));
@@ -1905,35 +1415,6 @@ IceInternal::isMulticast(const Address& addr)
1905
1415
  {
1906
1416
  return IN6_IS_ADDR_MULTICAST(&addr.saIn6.sin6_addr);
1907
1417
  }
1908
- #else
1909
- if(addr.host == nullptr)
1910
- {
1911
- return false;
1912
- }
1913
- //
1914
- // Don't need to use string converters here, this is just to do a local
1915
- // comparison to find if the address is multicast.
1916
- //
1917
- string host = wstringToString(addr.host->RawName->Data());
1918
- string ip = IceUtilInternal::toUpper(host);
1919
- vector<string> tokens;
1920
- IceUtilInternal::splitString(ip, ".", tokens);
1921
- if(tokens.size() == 4)
1922
- {
1923
- IceUtil::Int64 j;
1924
- if(IceUtilInternal::stringToInt64(tokens[0], j))
1925
- {
1926
- if(j >= 233 && j <= 239)
1927
- {
1928
- return true;
1929
- }
1930
- }
1931
- }
1932
- if(ip.find("::") != string::npos)
1933
- {
1934
- return ip.compare(0, 2, "FF") == 0;
1935
- }
1936
- #endif
1937
1418
  return false;
1938
1419
  }
1939
1420
 
@@ -2009,12 +1490,6 @@ IceInternal::setTcpBufSize(SOCKET fd, int rcvSize, int sndSize, const ProtocolIn
2009
1490
  }
2010
1491
  }
2011
1492
 
2012
- #ifdef ICE_OS_UWP
2013
- void
2014
- IceInternal::setBlock(SOCKET fd, bool)
2015
- {
2016
- }
2017
- #else
2018
1493
  void
2019
1494
  IceInternal::setBlock(SOCKET fd, bool block)
2020
1495
  {
@@ -2060,30 +1535,20 @@ IceInternal::setBlock(SOCKET fd, bool block)
2060
1535
  }
2061
1536
  #endif
2062
1537
  }
2063
- #endif
2064
1538
 
2065
1539
  void
2066
1540
  IceInternal::setSendBufferSize(SOCKET fd, int sz)
2067
1541
  {
2068
- #ifndef ICE_OS_UWP
2069
1542
  if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, reinterpret_cast<char*>(&sz), int(sizeof(int))) == SOCKET_ERROR)
2070
1543
  {
2071
1544
  closeSocketNoThrow(fd);
2072
1545
  throw SocketException(__FILE__, __LINE__, getSocketErrno());
2073
1546
  }
2074
- #else
2075
- StreamSocket^ stream = dynamic_cast<StreamSocket^>(fd);
2076
- if(stream != nullptr)
2077
- {
2078
- stream->Control->OutboundBufferSizeInBytes = sz;
2079
- }
2080
- #endif
2081
1547
  }
2082
1548
 
2083
1549
  int
2084
1550
  IceInternal::getSendBufferSize(SOCKET fd)
2085
1551
  {
2086
- #ifndef ICE_OS_UWP
2087
1552
  int sz;
2088
1553
  socklen_t len = sizeof(sz);
2089
1554
  if(getsockopt(fd, SOL_SOCKET, SO_SNDBUF, reinterpret_cast<char*>(&sz), &len) == SOCKET_ERROR ||
@@ -2093,22 +1558,8 @@ IceInternal::getSendBufferSize(SOCKET fd)
2093
1558
  throw SocketException(__FILE__, __LINE__, getSocketErrno());
2094
1559
  }
2095
1560
  return sz;
2096
- #else
2097
- StreamSocket^ stream = dynamic_cast<StreamSocket^>(fd);
2098
- if(stream != nullptr)
2099
- {
2100
- return stream->Control->OutboundBufferSizeInBytes;
2101
- }
2102
- return 0; // Not supported
2103
- #endif
2104
1561
  }
2105
1562
 
2106
- #ifdef ICE_OS_UWP
2107
- void
2108
- IceInternal::setRecvBufferSize(SOCKET, int)
2109
- {
2110
- }
2111
- #else
2112
1563
  void
2113
1564
  IceInternal::setRecvBufferSize(SOCKET fd, int sz)
2114
1565
  {
@@ -2118,12 +1569,10 @@ IceInternal::setRecvBufferSize(SOCKET fd, int sz)
2118
1569
  throw SocketException(__FILE__, __LINE__, getSocketErrno());
2119
1570
  }
2120
1571
  }
2121
- #endif
2122
1572
 
2123
1573
  int
2124
1574
  IceInternal::getRecvBufferSize(SOCKET fd)
2125
1575
  {
2126
- #ifndef ICE_OS_UWP
2127
1576
  int sz;
2128
1577
  socklen_t len = sizeof(sz);
2129
1578
  if(getsockopt(fd, SOL_SOCKET, SO_RCVBUF, reinterpret_cast<char*>(&sz), &len) == SOCKET_ERROR ||
@@ -2133,12 +1582,8 @@ IceInternal::getRecvBufferSize(SOCKET fd)
2133
1582
  throw SocketException(__FILE__, __LINE__, getSocketErrno());
2134
1583
  }
2135
1584
  return sz;
2136
- #else
2137
- return 0; // Not supported
2138
- #endif
2139
1585
  }
2140
1586
 
2141
- #ifndef ICE_OS_UWP
2142
1587
  void
2143
1588
  IceInternal::setMcastGroup(SOCKET fd, const Address& group, const string& intf)
2144
1589
  {
@@ -2173,55 +1618,7 @@ IceInternal::setMcastGroup(SOCKET fd, const Address& group, const string& intf)
2173
1618
  }
2174
1619
  }
2175
1620
  }
2176
- #else
2177
- void
2178
- IceInternal::setMcastGroup(SOCKET fd, const Address& group, const string&)
2179
- {
2180
- try
2181
- {
2182
- //
2183
- // NOTE: UWP mcast interface is set earlier in doBind.
2184
- //
2185
- safe_cast<DatagramSocket^>(fd)->JoinMulticastGroup(group.host);
2186
-
2187
- //
2188
- // BUGFIX DatagramSocket will not recive any messages from a multicast group if the
2189
- // messages originate in the same host until the socket is used to send at least one
2190
- // message. We send a valiate connection message that the peers will ignore to workaround
2191
- // the issue.
2192
- //
2193
- auto out = IceInternal::runSync(safe_cast<DatagramSocket^>(fd)->GetOutputStreamAsync(group.host, group.port));
2194
- auto writer = ref new DataWriter(out);
2195
1621
 
2196
- OutputStream os;
2197
- os.write(magic[0]);
2198
- os.write(magic[1]);
2199
- os.write(magic[2]);
2200
- os.write(magic[3]);
2201
- os.write(currentProtocol);
2202
- os.write(currentProtocolEncoding);
2203
- os.write(validateConnectionMsg);
2204
- os.write(static_cast<Byte>(0)); // Compression status (always zero for validate connection).
2205
- os.write(headerSize); // Message size.
2206
- os.i = os.b.begin();
2207
-
2208
- writer->WriteBytes(ref new Array<unsigned char>(&*os.i, static_cast<unsigned int>(headerSize)));
2209
-
2210
- IceInternal::runSync(writer->StoreAsync());
2211
- }
2212
- catch(Platform::Exception^ pex)
2213
- {
2214
- throw SocketException(__FILE__, __LINE__, (int)SocketError::GetStatus(pex->HResult));
2215
- }
2216
- }
2217
- #endif
2218
-
2219
- #ifdef ICE_OS_UWP
2220
- void
2221
- IceInternal::setMcastInterface(SOCKET, const string&, const Address&)
2222
- {
2223
- }
2224
- #else
2225
1622
  void
2226
1623
  IceInternal::setMcastInterface(SOCKET fd, const string& intf, const Address& addr)
2227
1624
  {
@@ -2242,14 +1639,7 @@ IceInternal::setMcastInterface(SOCKET fd, const string& intf, const Address& add
2242
1639
  throw SocketException(__FILE__, __LINE__, getSocketErrno());
2243
1640
  }
2244
1641
  }
2245
- #endif
2246
1642
 
2247
- #ifdef ICE_OS_UWP
2248
- void
2249
- IceInternal::setMcastTtl(SOCKET, int, const Address&)
2250
- {
2251
- }
2252
- #else
2253
1643
  void
2254
1644
  IceInternal::setMcastTtl(SOCKET fd, int ttl, const Address& addr)
2255
1645
  {
@@ -2268,14 +1658,7 @@ IceInternal::setMcastTtl(SOCKET fd, int ttl, const Address& addr)
2268
1658
  throw SocketException(__FILE__, __LINE__, getSocketErrno());
2269
1659
  }
2270
1660
  }
2271
- #endif
2272
1661
 
2273
- #ifdef ICE_OS_UWP
2274
- void
2275
- IceInternal::setReuseAddress(SOCKET, bool)
2276
- {
2277
- }
2278
- #else
2279
1662
  void
2280
1663
  IceInternal::setReuseAddress(SOCKET fd, bool reuse)
2281
1664
  {
@@ -2286,119 +1669,7 @@ IceInternal::setReuseAddress(SOCKET fd, bool reuse)
2286
1669
  throw SocketException(__FILE__, __LINE__, getSocketErrno());
2287
1670
  }
2288
1671
  }
2289
- #endif
2290
-
2291
- #ifdef ICE_OS_UWP
2292
- namespace
2293
- {
2294
-
2295
- void
2296
- checkResultAndWait(IAsyncAction^ action)
2297
- {
2298
- auto status = action->Status;
2299
- switch(status)
2300
- {
2301
- case Windows::Foundation::AsyncStatus::Started:
2302
- {
2303
- promise<HRESULT> p;
2304
- action->Completed = ref new AsyncActionCompletedHandler(
2305
- [&p] (IAsyncAction^ action, Windows::Foundation::AsyncStatus status)
2306
- {
2307
- p.set_value(status != Windows::Foundation::AsyncStatus::Completed ? action->ErrorCode.Value : 0);
2308
- });
2309
-
2310
- HRESULT result = p.get_future().get();
2311
- if(result)
2312
- {
2313
- checkErrorCode(__FILE__, __LINE__, result);
2314
- }
2315
- break;
2316
- }
2317
- case Windows::Foundation::AsyncStatus::Error:
2318
- {
2319
- checkErrorCode(__FILE__, __LINE__, action->ErrorCode.Value);
2320
- break;
2321
- }
2322
- default:
2323
- {
2324
- break;
2325
- }
2326
- }
2327
- }
2328
1672
 
2329
- }
2330
- #endif
2331
-
2332
- #ifdef ICE_OS_UWP
2333
- Address
2334
- IceInternal::doBind(SOCKET fd, const Address& addr, const string& intf)
2335
- {
2336
- Address local;
2337
- try
2338
- {
2339
- StreamSocketListener^ listener = dynamic_cast<StreamSocketListener^>(fd);
2340
- if(listener != nullptr)
2341
- {
2342
- if(addr.host == nullptr) // inaddr_any
2343
- {
2344
- checkResultAndWait(listener->BindServiceNameAsync(addr.port));
2345
- }
2346
- else
2347
- {
2348
- checkResultAndWait(listener->BindEndpointAsync(addr.host, addr.port));
2349
- }
2350
- local.host = addr.host;
2351
- local.port = listener->Information->LocalPort;
2352
- }
2353
-
2354
- DatagramSocket^ datagram = dynamic_cast<DatagramSocket^>(fd);
2355
- if(datagram != nullptr)
2356
- {
2357
- if(addr.host == nullptr) // inaddr_any
2358
- {
2359
- NetworkAdapter^ adapter;
2360
- if(!intf.empty())
2361
- {
2362
- auto s = ref new String(Ice::stringToWstring(intf).c_str());
2363
- auto profiles = NetworkInformation::GetConnectionProfiles();
2364
- for(auto i = profiles->First(); adapter == nullptr && i->HasCurrent; i->MoveNext())
2365
- {
2366
- auto names = i->Current->GetNetworkNames();
2367
- for(auto j = names->First(); adapter == nullptr && j->HasCurrent; j->MoveNext())
2368
- {
2369
- if(j->Current->Equals(s))
2370
- {
2371
- adapter = i->Current->NetworkAdapter;
2372
- }
2373
- }
2374
- }
2375
- }
2376
-
2377
- if(adapter)
2378
- {
2379
- checkResultAndWait(datagram->BindServiceNameAsync(addr.port, adapter));
2380
- }
2381
- else
2382
- {
2383
- checkResultAndWait(datagram->BindServiceNameAsync(addr.port));
2384
- }
2385
- }
2386
- else
2387
- {
2388
- checkResultAndWait(datagram->BindEndpointAsync(addr.host, addr.port));
2389
- }
2390
- local.host = datagram->Information->LocalAddress;
2391
- local.port = datagram->Information->LocalPort;
2392
- }
2393
- }
2394
- catch(const Ice::SocketException&)
2395
- {
2396
- closeSocketNoThrow(fd);
2397
- throw;
2398
- }
2399
- return local;
2400
- }
2401
- #else
2402
1673
  Address
2403
1674
  IceInternal::doBind(SOCKET fd, const Address& addr, const string&)
2404
1675
  {
@@ -2413,17 +1684,14 @@ IceInternal::doBind(SOCKET fd, const Address& addr, const string&)
2413
1684
 
2414
1685
  Address local;
2415
1686
  socklen_t len = static_cast<socklen_t>(sizeof(sockaddr_storage));
2416
- # ifdef NDEBUG
1687
+ #ifdef NDEBUG
2417
1688
  getsockname(fd, &local.sa, &len);
2418
- # else
1689
+ #else
2419
1690
  int ret = getsockname(fd, &local.sa, &len);
2420
1691
  assert(ret != SOCKET_ERROR);
2421
- # endif
1692
+ #endif
2422
1693
  return local;
2423
1694
  }
2424
- #endif
2425
-
2426
- #ifndef ICE_OS_UWP
2427
1695
 
2428
1696
  Address
2429
1697
  IceInternal::getNumericAddress(const std::string& address)
@@ -2865,94 +2133,6 @@ IceInternal::createPipe(SOCKET fds[2])
2865
2133
  #endif
2866
2134
  }
2867
2135
 
2868
- #else // ICE_OS_UWP
2869
-
2870
- void
2871
- IceInternal::checkConnectErrorCode(const char* file, int line, HRESULT herr)
2872
- {
2873
- if(herr == E_ACCESSDENIED)
2874
- {
2875
- throw SocketException(file, line, static_cast<int>(herr));
2876
- }
2877
- SocketErrorStatus error = SocketError::GetStatus(herr);
2878
- if(error == SocketErrorStatus::ConnectionRefused)
2879
- {
2880
- throw ConnectionRefusedException(file, line, static_cast<int>(error));
2881
- }
2882
- else if(error == SocketErrorStatus::NetworkDroppedConnectionOnReset ||
2883
- error == SocketErrorStatus::ConnectionTimedOut ||
2884
- error == SocketErrorStatus::NetworkIsUnreachable ||
2885
- error == SocketErrorStatus::UnreachableHost ||
2886
- error == SocketErrorStatus::ConnectionResetByPeer ||
2887
- error == SocketErrorStatus::SoftwareCausedConnectionAbort)
2888
- {
2889
- throw ConnectFailedException(file, line, static_cast<int>(error));
2890
- }
2891
- else if(error == SocketErrorStatus::HostNotFound)
2892
- {
2893
- throw DNSException(file, line, static_cast<int>(error), "");
2894
- }
2895
- else
2896
- {
2897
- throw SocketException(file, line, static_cast<int>(error));
2898
- }
2899
- }
2900
-
2901
- void
2902
- IceInternal::checkErrorCode(const char* file, int line, HRESULT herr)
2903
- {
2904
- if(herr == E_ACCESSDENIED)
2905
- {
2906
- throw SocketException(file, line, static_cast<int>(herr));
2907
- }
2908
- SocketErrorStatus error = SocketError::GetStatus(herr);
2909
- if(error == SocketErrorStatus::NetworkDroppedConnectionOnReset ||
2910
- error == SocketErrorStatus::SoftwareCausedConnectionAbort ||
2911
- error == SocketErrorStatus::ConnectionResetByPeer)
2912
- {
2913
- throw ConnectionLostException(file, line, static_cast<int>(error));
2914
- }
2915
- else if(error == SocketErrorStatus::HostNotFound)
2916
- {
2917
- throw DNSException(file, line, static_cast<int>(error), "");
2918
- }
2919
- else
2920
- {
2921
- throw SocketException(file, line, static_cast<int>(error));
2922
- }
2923
- }
2924
-
2925
- //
2926
- // UWP impose some restriction on operations that block when run from
2927
- // STA thread and throws concurrency::invalid_operation. We cannot
2928
- // directly call task::get or task::way, this helper method is used to
2929
- // workaround this limitation.
2930
- //
2931
- void
2932
- IceInternal::runSync(Windows::Foundation::IAsyncAction^ action)
2933
- {
2934
- std::promise<void> p;
2935
-
2936
- concurrency::create_task(action).then(
2937
- [&p](concurrency::task<void> t)
2938
- {
2939
- try
2940
- {
2941
- t.get();
2942
- p.set_value();
2943
- }
2944
- catch(...)
2945
- {
2946
- p.set_exception(std::current_exception());
2947
- }
2948
- },
2949
- concurrency::task_continuation_context::use_arbitrary());
2950
-
2951
- return p.get_future().get();
2952
- }
2953
-
2954
- #endif
2955
-
2956
2136
  #if defined(ICE_USE_IOCP)
2957
2137
  void
2958
2138
  IceInternal::doConnectAsync(SOCKET fd, const Address& addr, const Address& sourceAddr, AsyncInfo& info)
@@ -3062,14 +2242,8 @@ IceInternal::doFinishConnectAsync(SOCKET fd, AsyncInfo& info)
3062
2242
  bool
3063
2243
  IceInternal::isIpAddress(const string& name)
3064
2244
  {
3065
- #ifdef ICE_OS_UWP
3066
- HostName^ hostname = ref new HostName(ref new String(stringToWstring(name,
3067
- getProcessStringConverter()).c_str()));
3068
- return hostname->Type == HostNameType::Ipv4 || hostname->Type == HostNameType::Ipv6;
3069
- #else
3070
2245
  in_addr addr;
3071
2246
  in6_addr addr6;
3072
2247
 
3073
2248
  return inet_pton(AF_INET, name.c_str(), &addr) > 0 || inet_pton(AF_INET6, name.c_str(), &addr6) > 0;
3074
- #endif
3075
2249
  }