zeroc-ice 3.6.5 → 3.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (777) hide show
  1. checksums.yaml +5 -5
  2. data/ICE_LICENSE +17 -17
  3. data/LICENSE +12 -12
  4. data/bin/slice2rb +1 -6
  5. data/ext/Communicator.cpp +223 -61
  6. data/ext/Communicator.h +1 -6
  7. data/ext/Config.h +23 -7
  8. data/ext/Connection.cpp +108 -76
  9. data/ext/Connection.h +4 -6
  10. data/ext/Endpoint.cpp +16 -54
  11. data/ext/Endpoint.h +1 -6
  12. data/ext/ImplicitContext.cpp +1 -10
  13. data/ext/ImplicitContext.h +1 -6
  14. data/ext/Init.cpp +4 -6
  15. data/ext/Logger.cpp +1 -6
  16. data/ext/Logger.h +1 -6
  17. data/ext/Operation.cpp +38 -54
  18. data/ext/Operation.h +1 -6
  19. data/ext/Properties.cpp +3 -8
  20. data/ext/Properties.h +1 -6
  21. data/ext/Proxy.cpp +111 -70
  22. data/ext/Proxy.h +1 -6
  23. data/ext/Slice.cpp +5 -20
  24. data/ext/Slice.h +1 -6
  25. data/ext/Types.cpp +313 -224
  26. data/ext/Types.h +118 -71
  27. data/ext/Util.cpp +69 -36
  28. data/ext/Util.h +117 -42
  29. data/ext/ValueFactoryManager.cpp +440 -0
  30. data/ext/ValueFactoryManager.h +95 -0
  31. data/ext/extconf.rb +52 -48
  32. data/ext/ice/cpp/include/Ice/Application.h +275 -105
  33. data/ext/ice/cpp/include/Ice/AsyncResult.h +124 -337
  34. data/ext/ice/cpp/include/Ice/AsyncResultF.h +4 -7
  35. data/ext/ice/cpp/include/Ice/BatchRequestInterceptor.h +39 -16
  36. data/ext/ice/cpp/include/Ice/BatchRequestQueueF.h +1 -6
  37. data/ext/ice/cpp/include/Ice/Buffer.h +10 -15
  38. data/ext/ice/cpp/include/Ice/CommunicatorAsync.h +56 -17
  39. data/ext/ice/cpp/include/Ice/Comparable.h +205 -0
  40. data/ext/ice/cpp/include/Ice/Config.h +16 -39
  41. data/ext/ice/cpp/include/Ice/ConnectionAsync.h +203 -16
  42. data/ext/ice/cpp/include/Ice/ConnectionIF.h +7 -6
  43. data/ext/ice/cpp/include/Ice/ConsoleUtil.h +23 -0
  44. data/ext/ice/cpp/include/Ice/DefaultValueFactory.h +57 -0
  45. data/ext/ice/cpp/include/Ice/DispatchInterceptor.h +20 -12
  46. data/ext/ice/cpp/include/Ice/Dispatcher.h +35 -19
  47. data/ext/ice/cpp/include/Ice/DynamicLibrary.h +7 -10
  48. data/ext/ice/cpp/include/Ice/DynamicLibraryF.h +1 -6
  49. data/ext/ice/cpp/include/Ice/Exception.h +110 -63
  50. data/ext/ice/cpp/include/Ice/ExceptionHelpers.h +74 -0
  51. data/ext/ice/cpp/include/Ice/FactoryTable.h +22 -18
  52. data/ext/ice/cpp/include/Ice/FactoryTableInit.h +28 -31
  53. data/ext/ice/cpp/include/Ice/Format.h +17 -18
  54. data/ext/ice/cpp/include/Ice/Functional.h +38 -38
  55. data/ext/ice/cpp/include/Ice/GCObject.h +9 -10
  56. data/ext/ice/cpp/include/Ice/Handle.h +6 -16
  57. data/ext/ice/cpp/include/Ice/Ice.h +9 -10
  58. data/ext/ice/cpp/include/Ice/IconvStringConverter.h +377 -0
  59. data/ext/ice/cpp/include/Ice/Incoming.h +132 -38
  60. data/ext/ice/cpp/include/Ice/IncomingAsync.h +109 -31
  61. data/ext/ice/cpp/include/Ice/IncomingAsyncF.h +7 -6
  62. data/ext/ice/cpp/include/Ice/Initialize.h +872 -60
  63. data/ext/ice/cpp/include/Ice/InputStream.h +1514 -0
  64. data/ext/ice/cpp/include/Ice/InstanceF.h +1 -7
  65. data/ext/ice/cpp/include/Ice/InterfaceByValue.h +57 -0
  66. data/ext/ice/cpp/include/Ice/LocalObject.h +13 -14
  67. data/ext/ice/cpp/include/Ice/LocalObjectF.h +1 -6
  68. data/ext/ice/cpp/include/Ice/LoggerUtil.h +56 -24
  69. data/ext/ice/cpp/include/Ice/MetricsAdminI.h +124 -71
  70. data/ext/ice/cpp/include/Ice/MetricsFunctional.h +25 -10
  71. data/ext/ice/cpp/include/Ice/MetricsObserverI.h +116 -32
  72. data/ext/ice/cpp/include/Ice/NativePropertiesAdmin.h +61 -30
  73. data/ext/ice/cpp/include/Ice/Object.h +413 -78
  74. data/ext/ice/cpp/include/Ice/ObjectF.h +12 -8
  75. data/ext/ice/cpp/include/Ice/ObserverHelper.h +18 -13
  76. data/ext/ice/cpp/include/Ice/Optional.h +1114 -0
  77. data/ext/ice/cpp/include/Ice/OutgoingAsync.h +684 -89
  78. data/ext/ice/cpp/include/Ice/OutgoingAsyncF.h +12 -11
  79. data/ext/ice/cpp/include/Ice/OutputStream.h +1092 -0
  80. data/ext/ice/cpp/include/Ice/Protocol.h +49 -17
  81. data/ext/ice/cpp/include/Ice/Proxy.h +3438 -745
  82. data/ext/ice/cpp/include/Ice/ProxyF.h +13 -38
  83. data/ext/ice/cpp/include/Ice/ProxyFactoryF.h +1 -6
  84. data/ext/ice/cpp/include/Ice/ProxyHandle.h +43 -55
  85. data/ext/ice/cpp/include/Ice/ReferenceF.h +1 -6
  86. data/ext/ice/cpp/include/Ice/RegisterPlugins.h +84 -12
  87. data/ext/ice/cpp/include/Ice/RequestHandlerF.h +10 -9
  88. data/ext/ice/cpp/include/Ice/ResponseHandlerF.h +6 -6
  89. data/ext/ice/cpp/include/Ice/SHA1.h +42 -0
  90. data/ext/ice/cpp/include/Ice/ServantManagerF.h +1 -6
  91. data/ext/ice/cpp/include/Ice/Service.h +273 -154
  92. data/ext/ice/cpp/include/Ice/SliceChecksums.h +5 -6
  93. data/ext/ice/cpp/include/Ice/SlicedData.h +121 -53
  94. data/ext/ice/cpp/include/Ice/SlicedDataF.h +17 -11
  95. data/ext/ice/cpp/include/Ice/StreamHelpers.h +453 -140
  96. data/ext/ice/cpp/include/Ice/StringConverter.h +78 -0
  97. data/ext/ice/cpp/include/Ice/ThreadPoolF.h +1 -6
  98. data/ext/ice/cpp/include/Ice/UUID.h +19 -0
  99. data/ext/ice/cpp/include/{IceUtil → Ice}/UniquePtr.h +22 -28
  100. data/ext/ice/cpp/include/Ice/UniqueRef.h +97 -0
  101. data/ext/ice/cpp/include/Ice/UserExceptionFactory.h +45 -13
  102. data/ext/ice/cpp/include/Ice/Value.h +139 -0
  103. data/ext/ice/cpp/include/Ice/ValueF.h +21 -0
  104. data/ext/ice/cpp/include/IceSSL/Config.h +8 -28
  105. data/ext/ice/cpp/include/IceSSL/IceSSL.h +17 -11
  106. data/ext/ice/cpp/include/IceSSL/OpenSSL.h +147 -0
  107. data/ext/ice/cpp/include/IceSSL/Plugin.h +461 -448
  108. data/ext/ice/cpp/include/IceSSL/SChannel.h +72 -0
  109. data/ext/ice/cpp/include/IceSSL/SecureTransport.h +72 -0
  110. data/ext/ice/cpp/include/IceSSL/UWP.h +62 -0
  111. data/ext/ice/cpp/include/IceUtil/Atomic.h +7 -14
  112. data/ext/ice/cpp/include/IceUtil/Cond.h +17 -23
  113. data/ext/ice/cpp/include/IceUtil/Config.h +166 -46
  114. data/ext/ice/cpp/include/IceUtil/ConsoleUtil.h +92 -0
  115. data/ext/ice/cpp/include/IceUtil/CountDownLatch.h +5 -10
  116. data/ext/ice/cpp/include/IceUtil/CtrlCHandler.h +63 -41
  117. data/ext/ice/cpp/include/IceUtil/DisableWarnings.h +5 -13
  118. data/ext/ice/cpp/include/IceUtil/Exception.h +284 -75
  119. data/ext/ice/cpp/include/IceUtil/FileUtil.h +143 -0
  120. data/ext/ice/cpp/include/IceUtil/Functional.h +4 -6
  121. data/ext/ice/cpp/include/IceUtil/Handle.h +11 -16
  122. data/ext/ice/cpp/include/IceUtil/IceUtil.h +4 -15
  123. data/ext/ice/cpp/include/IceUtil/InputUtil.h +3 -8
  124. data/ext/ice/cpp/include/IceUtil/Iterator.h +2 -7
  125. data/ext/ice/cpp/include/IceUtil/Lock.h +8 -15
  126. data/ext/ice/cpp/include/IceUtil/Monitor.h +1 -7
  127. data/ext/ice/cpp/include/IceUtil/Mutex.h +19 -23
  128. data/ext/ice/cpp/include/IceUtil/MutexProtocol.h +2 -7
  129. data/ext/ice/cpp/include/IceUtil/MutexPtrLock.h +4 -9
  130. data/ext/ice/cpp/include/IceUtil/MutexPtrTryLock.h +4 -9
  131. data/ext/ice/cpp/include/IceUtil/Optional.h +134 -23
  132. data/ext/ice/cpp/include/IceUtil/Options.h +17 -23
  133. data/ext/ice/cpp/include/IceUtil/OutputUtil.h +61 -37
  134. data/ext/ice/cpp/include/IceUtil/PopDisableWarnings.h +6 -11
  135. data/ext/ice/cpp/include/IceUtil/PushDisableWarnings.h +18 -15
  136. data/ext/ice/cpp/include/IceUtil/Random.h +39 -8
  137. data/ext/ice/cpp/include/IceUtil/RecMutex.h +7 -13
  138. data/ext/ice/cpp/include/IceUtil/ResourceConfig.h +53 -0
  139. data/ext/ice/cpp/include/IceUtil/ScannerConfig.h +10 -15
  140. data/ext/ice/cpp/include/IceUtil/ScopedArray.h +8 -7
  141. data/ext/ice/cpp/include/IceUtil/Shared.h +5 -12
  142. data/ext/ice/cpp/{src → include}/IceUtil/StopWatch.h +2 -7
  143. data/ext/ice/cpp/include/IceUtil/StringConverter.h +146 -126
  144. data/ext/ice/cpp/include/IceUtil/StringUtil.h +32 -26
  145. data/ext/ice/cpp/include/IceUtil/Thread.h +10 -17
  146. data/ext/ice/cpp/include/IceUtil/ThreadException.h +33 -47
  147. data/ext/ice/cpp/include/IceUtil/Time.h +3 -8
  148. data/ext/ice/cpp/include/IceUtil/Timer.h +18 -18
  149. data/ext/ice/cpp/include/IceUtil/UUID.h +6 -7
  150. data/ext/ice/cpp/include/IceUtil/UndefSysMacros.h +1 -6
  151. data/ext/ice/cpp/include/generated/Ice/BuiltinSequences.h +170 -0
  152. data/ext/ice/cpp/include/generated/Ice/Communicator.h +1156 -0
  153. data/ext/ice/cpp/include/{Ice → generated/Ice}/CommunicatorF.h +51 -16
  154. data/ext/ice/cpp/include/generated/Ice/Connection.h +1660 -0
  155. data/ext/ice/cpp/include/generated/Ice/ConnectionF.h +119 -0
  156. data/ext/ice/cpp/include/generated/Ice/Current.h +322 -0
  157. data/ext/ice/cpp/include/generated/Ice/Endpoint.h +943 -0
  158. data/ext/ice/cpp/include/generated/Ice/EndpointF.h +166 -0
  159. data/ext/ice/cpp/include/generated/Ice/EndpointTypes.h +118 -0
  160. data/ext/ice/cpp/include/{Ice → generated/Ice}/FacetMap.h +31 -15
  161. data/ext/ice/cpp/include/generated/Ice/Identity.h +264 -0
  162. data/ext/ice/cpp/include/generated/Ice/ImplicitContext.h +278 -0
  163. data/ext/ice/cpp/include/{Ice → generated/Ice}/ImplicitContextF.h +51 -16
  164. data/ext/ice/cpp/include/generated/Ice/Instrumentation.h +1143 -0
  165. data/ext/ice/cpp/include/generated/Ice/InstrumentationF.h +128 -0
  166. data/ext/ice/cpp/include/generated/Ice/LocalException.h +7041 -0
  167. data/ext/ice/cpp/include/generated/Ice/Locator.h +3850 -0
  168. data/ext/ice/cpp/include/generated/Ice/LocatorF.h +147 -0
  169. data/ext/ice/cpp/include/generated/Ice/Logger.h +231 -0
  170. data/ext/ice/cpp/include/{Ice → generated/Ice}/LoggerF.h +51 -16
  171. data/ext/ice/cpp/include/generated/Ice/Metrics.h +4717 -0
  172. data/ext/ice/cpp/include/generated/Ice/ObjectAdapter.h +1175 -0
  173. data/ext/ice/cpp/include/{Ice → generated/Ice}/ObjectAdapterF.h +51 -16
  174. data/ext/ice/cpp/include/generated/Ice/ObjectFactory.h +197 -0
  175. data/ext/ice/cpp/include/generated/Ice/Plugin.h +306 -0
  176. data/ext/ice/cpp/include/generated/Ice/PluginF.h +110 -0
  177. data/ext/ice/cpp/include/generated/Ice/Process.h +971 -0
  178. data/ext/ice/cpp/include/generated/Ice/ProcessF.h +125 -0
  179. data/ext/ice/cpp/include/generated/Ice/Properties.h +446 -0
  180. data/ext/ice/cpp/include/generated/Ice/PropertiesAdmin.h +1360 -0
  181. data/ext/ice/cpp/include/generated/Ice/PropertiesF.h +134 -0
  182. data/ext/ice/cpp/include/generated/Ice/RemoteLogger.h +2689 -0
  183. data/ext/ice/cpp/include/generated/Ice/Router.h +1838 -0
  184. data/ext/ice/cpp/include/generated/Ice/RouterF.h +125 -0
  185. data/ext/ice/cpp/include/generated/Ice/ServantLocator.h +299 -0
  186. data/ext/ice/cpp/include/{Ice → generated/Ice}/ServantLocatorF.h +51 -16
  187. data/ext/ice/cpp/include/{Ice → generated/Ice}/SliceChecksumDict.h +34 -14
  188. data/ext/ice/cpp/include/generated/Ice/ValueFactory.h +318 -0
  189. data/ext/ice/cpp/include/generated/Ice/Version.h +357 -0
  190. data/ext/ice/cpp/include/generated/IceSSL/ConnectionInfo.h +223 -0
  191. data/ext/ice/cpp/include/generated/IceSSL/ConnectionInfoF.h +101 -0
  192. data/ext/ice/cpp/include/generated/IceSSL/EndpointInfo.h +181 -0
  193. data/ext/ice/cpp/src/Ice/ACM.cpp +38 -27
  194. data/ext/ice/cpp/src/Ice/ACM.h +9 -7
  195. data/ext/ice/cpp/src/Ice/ACMF.h +30 -0
  196. data/ext/ice/cpp/src/Ice/Acceptor.cpp +6 -6
  197. data/ext/ice/cpp/src/Ice/Acceptor.h +4 -8
  198. data/ext/ice/cpp/src/Ice/AcceptorF.h +1 -6
  199. data/ext/ice/cpp/src/Ice/ArgVector.cpp +59 -0
  200. data/ext/ice/cpp/src/Ice/ArgVector.h +36 -0
  201. data/ext/ice/cpp/src/Ice/AsyncResult.cpp +15 -544
  202. data/ext/ice/cpp/src/Ice/Base64.cpp +22 -28
  203. data/ext/ice/cpp/src/Ice/Base64.h +1 -6
  204. data/ext/ice/cpp/src/Ice/BatchRequestQueue.cpp +41 -18
  205. data/ext/ice/cpp/src/Ice/BatchRequestQueue.h +15 -15
  206. data/ext/ice/cpp/src/Ice/Buffer.cpp +75 -18
  207. data/ext/ice/cpp/src/Ice/BuiltinSequences.cpp +21 -12
  208. data/ext/ice/cpp/src/Ice/CollocatedRequestHandler.cpp +86 -197
  209. data/ext/ice/cpp/src/Ice/CollocatedRequestHandler.h +17 -23
  210. data/ext/ice/cpp/src/Ice/Communicator.cpp +43 -15
  211. data/ext/ice/cpp/src/Ice/CommunicatorF.cpp +28 -11
  212. data/ext/ice/cpp/src/Ice/CommunicatorI.cpp +318 -117
  213. data/ext/ice/cpp/src/Ice/CommunicatorI.h +95 -40
  214. data/ext/ice/cpp/src/{IceUtil → Ice}/Cond.cpp +3 -8
  215. data/ext/ice/cpp/src/Ice/ConnectRequestHandler.cpp +55 -122
  216. data/ext/ice/cpp/src/Ice/ConnectRequestHandler.h +15 -31
  217. data/ext/ice/cpp/src/Ice/ConnectRequestHandlerF.h +6 -7
  218. data/ext/ice/cpp/src/Ice/Connection.cpp +111 -20
  219. data/ext/ice/cpp/src/Ice/ConnectionF.cpp +28 -11
  220. data/ext/ice/cpp/src/Ice/ConnectionFactory.cpp +300 -107
  221. data/ext/ice/cpp/src/Ice/ConnectionFactory.h +44 -28
  222. data/ext/ice/cpp/src/Ice/ConnectionFactoryF.h +30 -0
  223. data/ext/ice/cpp/src/Ice/ConnectionI.cpp +785 -713
  224. data/ext/ice/cpp/src/Ice/ConnectionI.h +105 -80
  225. data/ext/ice/cpp/src/Ice/ConnectionRequestHandler.cpp +2 -20
  226. data/ext/ice/cpp/src/Ice/ConnectionRequestHandler.h +5 -9
  227. data/ext/ice/cpp/src/Ice/Connector.cpp +6 -6
  228. data/ext/ice/cpp/src/Ice/Connector.h +4 -8
  229. data/ext/ice/cpp/src/Ice/ConnectorF.h +1 -6
  230. data/ext/ice/cpp/src/{IceUtil → Ice}/CountDownLatch.cpp +4 -9
  231. data/ext/ice/cpp/src/Ice/Current.cpp +30 -12
  232. data/ext/ice/cpp/src/Ice/DefaultsAndOverrides.cpp +10 -16
  233. data/ext/ice/cpp/src/Ice/DefaultsAndOverrides.h +1 -6
  234. data/ext/ice/cpp/src/Ice/DefaultsAndOverridesF.h +1 -6
  235. data/ext/ice/cpp/src/Ice/DispatchInterceptor.cpp +13 -25
  236. data/ext/ice/cpp/src/Ice/DynamicLibrary.cpp +34 -28
  237. data/ext/ice/cpp/src/Ice/Endpoint.cpp +107 -19
  238. data/ext/ice/cpp/src/Ice/EndpointF.cpp +28 -11
  239. data/ext/ice/cpp/src/Ice/EndpointFactory.cpp +152 -6
  240. data/ext/ice/cpp/src/Ice/EndpointFactory.h +72 -11
  241. data/ext/ice/cpp/src/Ice/EndpointFactoryF.h +1 -6
  242. data/ext/ice/cpp/src/Ice/EndpointFactoryManager.cpp +41 -36
  243. data/ext/ice/cpp/src/Ice/EndpointFactoryManager.h +10 -9
  244. data/ext/ice/cpp/src/Ice/EndpointFactoryManagerF.h +1 -6
  245. data/ext/ice/cpp/src/Ice/EndpointI.cpp +18 -7
  246. data/ext/ice/cpp/src/Ice/EndpointI.h +39 -18
  247. data/ext/ice/cpp/src/Ice/EndpointIF.h +18 -10
  248. data/ext/ice/cpp/src/Ice/EndpointTypes.cpp +19 -12
  249. data/ext/ice/cpp/src/Ice/EventHandler.cpp +6 -9
  250. data/ext/ice/cpp/src/Ice/EventHandler.h +13 -13
  251. data/ext/ice/cpp/src/Ice/EventHandlerF.h +5 -7
  252. data/ext/ice/cpp/src/Ice/Exception.cpp +102 -98
  253. data/ext/ice/cpp/src/Ice/FacetMap.cpp +21 -12
  254. data/ext/ice/cpp/src/Ice/FactoryTable.cpp +37 -33
  255. data/ext/ice/cpp/src/Ice/FactoryTableInit.cpp +2 -9
  256. data/ext/ice/cpp/src/Ice/GCObject.cpp +29 -31
  257. data/ext/ice/cpp/src/Ice/HashUtil.h +3 -9
  258. data/ext/ice/cpp/src/Ice/HttpParser.cpp +1 -7
  259. data/ext/ice/cpp/src/Ice/HttpParser.h +1 -6
  260. data/ext/ice/cpp/src/Ice/IPEndpointI.cpp +128 -111
  261. data/ext/ice/cpp/src/Ice/IPEndpointI.h +23 -19
  262. data/ext/ice/cpp/src/Ice/IPEndpointIF.h +6 -7
  263. data/ext/ice/cpp/src/Ice/IconvStringConverter.cpp +51 -0
  264. data/ext/ice/cpp/src/Ice/Identity.cpp +25 -16
  265. data/ext/ice/cpp/src/Ice/ImplicitContext.cpp +41 -13
  266. data/ext/ice/cpp/src/Ice/ImplicitContextF.cpp +28 -11
  267. data/ext/ice/cpp/src/Ice/ImplicitContextI.cpp +11 -28
  268. data/ext/ice/cpp/src/Ice/ImplicitContextI.h +7 -10
  269. data/ext/ice/cpp/src/Ice/Incoming.cpp +284 -255
  270. data/ext/ice/cpp/src/Ice/IncomingAsync.cpp +104 -214
  271. data/ext/ice/cpp/src/Ice/IncomingRequest.h +5 -9
  272. data/ext/ice/cpp/src/Ice/Initialize.cpp +309 -193
  273. data/ext/ice/cpp/src/Ice/InputStream.cpp +2726 -0
  274. data/ext/ice/cpp/src/Ice/Instance.cpp +243 -262
  275. data/ext/ice/cpp/src/Ice/Instance.h +30 -23
  276. data/ext/ice/cpp/src/Ice/Instrumentation.cpp +137 -23
  277. data/ext/ice/cpp/src/Ice/InstrumentationF.cpp +28 -11
  278. data/ext/ice/cpp/src/Ice/InstrumentationI.cpp +118 -105
  279. data/ext/ice/cpp/src/Ice/InstrumentationI.h +30 -36
  280. data/ext/ice/cpp/src/Ice/LocalException.cpp +1191 -422
  281. data/ext/ice/cpp/src/Ice/LocalObject.cpp +1 -7
  282. data/ext/ice/cpp/src/Ice/Locator.cpp +1282 -1222
  283. data/ext/ice/cpp/src/Ice/LocatorF.cpp +30 -12
  284. data/ext/ice/cpp/src/Ice/LocatorInfo.cpp +150 -186
  285. data/ext/ice/cpp/src/Ice/LocatorInfo.h +31 -36
  286. data/ext/ice/cpp/src/Ice/LocatorInfoF.h +1 -6
  287. data/ext/ice/cpp/src/Ice/Logger.cpp +39 -12
  288. data/ext/ice/cpp/src/Ice/LoggerAdminI.cpp +182 -88
  289. data/ext/ice/cpp/src/Ice/LoggerAdminI.h +4 -9
  290. data/ext/ice/cpp/src/Ice/LoggerF.cpp +28 -11
  291. data/ext/ice/cpp/src/Ice/LoggerI.cpp +26 -55
  292. data/ext/ice/cpp/src/Ice/LoggerI.h +7 -18
  293. data/ext/ice/cpp/src/Ice/LoggerUtil.cpp +10 -17
  294. data/ext/ice/cpp/src/Ice/Metrics.cpp +1280 -1107
  295. data/ext/ice/cpp/src/Ice/MetricsAdminI.cpp +58 -33
  296. data/ext/ice/cpp/src/Ice/MetricsObserverI.cpp +1 -7
  297. data/ext/ice/cpp/src/Ice/Network.cpp +753 -408
  298. data/ext/ice/cpp/src/Ice/Network.h +99 -36
  299. data/ext/ice/cpp/src/Ice/NetworkF.h +2 -7
  300. data/ext/ice/cpp/src/Ice/NetworkProxy.cpp +20 -19
  301. data/ext/ice/cpp/src/Ice/NetworkProxy.h +5 -7
  302. data/ext/ice/cpp/src/Ice/NetworkProxyF.h +1 -6
  303. data/ext/ice/cpp/src/Ice/OSLogLoggerI.cpp +57 -0
  304. data/ext/ice/cpp/src/Ice/OSLogLoggerI.h +40 -0
  305. data/ext/ice/cpp/src/Ice/Object.cpp +227 -232
  306. data/ext/ice/cpp/src/Ice/ObjectAdapter.cpp +45 -13
  307. data/ext/ice/cpp/src/Ice/ObjectAdapterF.cpp +28 -11
  308. data/ext/ice/cpp/src/Ice/ObjectAdapterFactory.cpp +83 -33
  309. data/ext/ice/cpp/src/Ice/ObjectAdapterFactory.h +13 -12
  310. data/ext/ice/cpp/src/Ice/ObjectAdapterFactoryF.h +25 -0
  311. data/ext/ice/cpp/src/Ice/ObjectAdapterI.cpp +298 -191
  312. data/ext/ice/cpp/src/Ice/ObjectAdapterI.h +44 -39
  313. data/ext/ice/cpp/src/Ice/ObjectFactory.cpp +41 -13
  314. data/ext/ice/cpp/src/Ice/ObserverHelper.cpp +9 -37
  315. data/ext/ice/cpp/src/Ice/OpaqueEndpointI.cpp +67 -67
  316. data/ext/ice/cpp/src/Ice/OpaqueEndpointI.h +15 -11
  317. data/ext/ice/cpp/src/Ice/OutgoingAsync.cpp +801 -366
  318. data/ext/ice/cpp/src/Ice/OutputStream.cpp +1367 -0
  319. data/ext/ice/cpp/src/Ice/Plugin.cpp +52 -14
  320. data/ext/ice/cpp/src/Ice/PluginF.cpp +28 -11
  321. data/ext/ice/cpp/src/Ice/PluginManagerI.cpp +27 -51
  322. data/ext/ice/cpp/src/Ice/PluginManagerI.h +7 -13
  323. data/ext/ice/cpp/src/Ice/Process.cpp +294 -128
  324. data/ext/ice/cpp/src/Ice/ProcessF.cpp +30 -12
  325. data/ext/ice/cpp/src/Ice/Properties.cpp +42 -15
  326. data/ext/ice/cpp/src/Ice/PropertiesAdmin.cpp +382 -340
  327. data/ext/ice/cpp/src/Ice/PropertiesAdminI.cpp +83 -24
  328. data/ext/ice/cpp/src/Ice/PropertiesAdminI.h +29 -10
  329. data/ext/ice/cpp/src/Ice/PropertiesF.cpp +30 -12
  330. data/ext/ice/cpp/src/Ice/PropertiesI.cpp +46 -57
  331. data/ext/ice/cpp/src/Ice/PropertiesI.h +18 -26
  332. data/ext/ice/cpp/src/Ice/PropertyNames.cpp +112 -19
  333. data/ext/ice/cpp/src/Ice/PropertyNames.h +4 -7
  334. data/ext/ice/cpp/src/Ice/Protocol.cpp +6 -19
  335. data/ext/ice/cpp/src/Ice/ProtocolInstance.cpp +37 -7
  336. data/ext/ice/cpp/src/Ice/ProtocolInstance.h +9 -25
  337. data/ext/ice/cpp/src/Ice/ProtocolInstanceF.h +1 -6
  338. data/ext/ice/cpp/src/Ice/ProtocolPluginFacade.cpp +6 -6
  339. data/ext/ice/cpp/src/Ice/ProtocolPluginFacade.h +3 -6
  340. data/ext/ice/cpp/src/Ice/ProtocolPluginFacadeF.h +1 -6
  341. data/ext/ice/cpp/src/Ice/Proxy.cpp +729 -957
  342. data/ext/ice/cpp/src/Ice/ProxyFactory.cpp +33 -38
  343. data/ext/ice/cpp/src/Ice/ProxyFactory.h +16 -16
  344. data/ext/ice/cpp/src/Ice/Reference.cpp +190 -106
  345. data/ext/ice/cpp/src/Ice/Reference.h +39 -28
  346. data/ext/ice/cpp/src/Ice/ReferenceFactory.cpp +69 -118
  347. data/ext/ice/cpp/src/Ice/ReferenceFactory.h +12 -17
  348. data/ext/ice/cpp/src/Ice/ReferenceFactoryF.h +1 -6
  349. data/ext/ice/cpp/src/Ice/RegisterPluginsInit.cpp +19 -9
  350. data/ext/ice/cpp/src/Ice/RegisterPluginsInit.h +1 -6
  351. data/ext/ice/cpp/src/Ice/RemoteLogger.cpp +766 -565
  352. data/ext/ice/cpp/src/Ice/ReplyStatus.h +1 -6
  353. data/ext/ice/cpp/src/Ice/RequestHandler.cpp +5 -8
  354. data/ext/ice/cpp/src/Ice/RequestHandler.h +10 -18
  355. data/ext/ice/cpp/src/Ice/RequestHandlerFactory.cpp +10 -11
  356. data/ext/ice/cpp/src/Ice/RequestHandlerFactory.h +2 -7
  357. data/ext/ice/cpp/src/Ice/ResponseHandler.cpp +3 -11
  358. data/ext/ice/cpp/src/Ice/ResponseHandler.h +16 -12
  359. data/ext/ice/cpp/src/Ice/RetryQueue.cpp +12 -20
  360. data/ext/ice/cpp/src/Ice/RetryQueue.h +7 -11
  361. data/ext/ice/cpp/src/Ice/RetryQueueF.h +1 -6
  362. data/ext/ice/cpp/src/Ice/Router.cpp +614 -492
  363. data/ext/ice/cpp/src/Ice/RouterF.cpp +30 -12
  364. data/ext/ice/cpp/src/Ice/RouterInfo.cpp +93 -99
  365. data/ext/ice/cpp/src/Ice/RouterInfo.h +42 -38
  366. data/ext/ice/cpp/src/Ice/RouterInfoF.h +1 -6
  367. data/ext/ice/cpp/src/{IceUtil → Ice}/SHA1.cpp +23 -28
  368. data/ext/ice/cpp/src/Ice/Selector.cpp +948 -855
  369. data/ext/ice/cpp/src/Ice/Selector.h +100 -152
  370. data/ext/ice/cpp/src/Ice/ServantLocator.cpp +41 -13
  371. data/ext/ice/cpp/src/Ice/ServantLocatorF.cpp +28 -11
  372. data/ext/ice/cpp/src/Ice/ServantManager.cpp +24 -45
  373. data/ext/ice/cpp/src/Ice/ServantManager.h +1 -6
  374. data/ext/ice/cpp/src/Ice/SharedContext.h +2 -7
  375. data/ext/ice/cpp/src/Ice/SliceChecksumDict.cpp +21 -12
  376. data/ext/ice/cpp/src/Ice/SliceChecksums.cpp +2 -7
  377. data/ext/ice/cpp/src/Ice/SlicedData.cpp +72 -25
  378. data/ext/ice/cpp/src/Ice/StreamSocket.cpp +208 -76
  379. data/ext/ice/cpp/src/Ice/StreamSocket.h +13 -9
  380. data/ext/ice/cpp/src/Ice/StringConverterPlugin.cpp +57 -22
  381. data/ext/ice/cpp/src/Ice/StringUtil.h +30 -0
  382. data/ext/ice/cpp/src/Ice/SysLoggerI.cpp +6 -7
  383. data/ext/ice/cpp/src/Ice/SysLoggerI.h +2 -8
  384. data/ext/ice/cpp/src/Ice/SystemdJournalI.cpp +66 -0
  385. data/ext/ice/cpp/src/Ice/SystemdJournalI.h +39 -0
  386. data/ext/ice/cpp/src/Ice/TcpAcceptor.cpp +169 -49
  387. data/ext/ice/cpp/src/Ice/TcpAcceptor.h +12 -10
  388. data/ext/ice/cpp/src/Ice/TcpConnector.cpp +6 -12
  389. data/ext/ice/cpp/src/Ice/TcpConnector.h +1 -7
  390. data/ext/ice/cpp/src/Ice/TcpEndpointI.cpp +51 -46
  391. data/ext/ice/cpp/src/Ice/TcpEndpointI.h +12 -14
  392. data/ext/ice/cpp/src/Ice/TcpTransceiver.cpp +17 -32
  393. data/ext/ice/cpp/src/Ice/TcpTransceiver.h +7 -15
  394. data/ext/ice/cpp/src/{IceUtil → Ice}/Thread.cpp +41 -54
  395. data/ext/ice/cpp/src/Ice/ThreadPool.cpp +242 -274
  396. data/ext/ice/cpp/src/Ice/ThreadPool.h +46 -48
  397. data/ext/ice/cpp/src/{IceUtil → Ice}/Timer.cpp +38 -26
  398. data/ext/ice/cpp/src/Ice/TraceLevels.cpp +2 -7
  399. data/ext/ice/cpp/src/Ice/TraceLevels.h +1 -6
  400. data/ext/ice/cpp/src/Ice/TraceLevelsF.h +2 -7
  401. data/ext/ice/cpp/src/Ice/TraceUtil.cpp +53 -36
  402. data/ext/ice/cpp/src/Ice/TraceUtil.h +13 -11
  403. data/ext/ice/cpp/src/Ice/Transceiver.cpp +1 -7
  404. data/ext/ice/cpp/src/Ice/Transceiver.h +8 -12
  405. data/ext/ice/cpp/src/Ice/TransceiverF.h +3 -8
  406. data/ext/ice/cpp/src/Ice/UdpConnector.cpp +5 -13
  407. data/ext/ice/cpp/src/Ice/UdpConnector.h +1 -7
  408. data/ext/ice/cpp/src/Ice/UdpEndpointI.cpp +118 -60
  409. data/ext/ice/cpp/src/Ice/UdpEndpointI.h +13 -10
  410. data/ext/ice/cpp/src/Ice/UdpTransceiver.cpp +177 -236
  411. data/ext/ice/cpp/src/Ice/UdpTransceiver.h +15 -22
  412. data/ext/ice/cpp/src/Ice/Value.cpp +76 -0
  413. data/ext/ice/cpp/src/Ice/ValueFactory.cpp +83 -0
  414. data/ext/ice/cpp/src/Ice/ValueFactoryManagerI.cpp +61 -0
  415. data/ext/ice/cpp/src/Ice/ValueFactoryManagerI.h +37 -0
  416. data/ext/ice/cpp/src/Ice/Version.cpp +25 -20
  417. data/ext/ice/cpp/src/Ice/VirtualShared.h +38 -0
  418. data/ext/ice/cpp/src/Ice/WSAcceptor.cpp +3 -14
  419. data/ext/ice/cpp/src/Ice/WSAcceptor.h +3 -12
  420. data/ext/ice/cpp/src/Ice/WSConnector.cpp +5 -16
  421. data/ext/ice/cpp/src/Ice/WSConnector.h +3 -11
  422. data/ext/ice/cpp/src/Ice/WSEndpoint.cpp +188 -89
  423. data/ext/ice/cpp/src/Ice/WSEndpoint.h +22 -37
  424. data/ext/ice/cpp/src/Ice/WSTransceiver.cpp +65 -66
  425. data/ext/ice/cpp/src/Ice/WSTransceiver.h +7 -27
  426. data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.cpp +596 -281
  427. data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.h +1383 -543
  428. data/ext/ice/cpp/src/IceDiscovery/LocatorI.cpp +89 -32
  429. data/ext/ice/cpp/src/IceDiscovery/LocatorI.h +59 -28
  430. data/ext/ice/cpp/src/IceDiscovery/LookupI.cpp +315 -66
  431. data/ext/ice/cpp/src/IceDiscovery/LookupI.h +83 -41
  432. data/ext/ice/cpp/src/IceDiscovery/PluginI.cpp +57 -64
  433. data/ext/ice/cpp/src/IceDiscovery/PluginI.h +3 -8
  434. data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.cpp +450 -172
  435. data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.h +863 -406
  436. data/ext/ice/cpp/src/IceLocatorDiscovery/Plugin.h +47 -0
  437. data/ext/ice/cpp/src/IceLocatorDiscovery/PluginI.cpp +636 -144
  438. data/ext/ice/cpp/src/IceSSL/AcceptorI.cpp +20 -173
  439. data/ext/ice/cpp/src/IceSSL/AcceptorI.h +8 -22
  440. data/ext/ice/cpp/src/IceSSL/CertificateI.cpp +279 -0
  441. data/ext/ice/cpp/src/IceSSL/CertificateI.h +64 -0
  442. data/ext/ice/cpp/src/IceSSL/ConnectionInfo.cpp +42 -17
  443. data/ext/ice/cpp/src/IceSSL/ConnectionInfoF.cpp +61 -0
  444. data/ext/ice/cpp/src/IceSSL/ConnectorI.cpp +15 -64
  445. data/ext/ice/cpp/src/IceSSL/ConnectorI.h +6 -18
  446. data/ext/ice/cpp/src/IceSSL/EndpointI.cpp +207 -204
  447. data/ext/ice/cpp/src/IceSSL/EndpointI.h +43 -40
  448. data/ext/ice/cpp/src/IceSSL/EndpointInfo.cpp +42 -16
  449. data/ext/ice/cpp/src/IceSSL/Instance.cpp +1 -11
  450. data/ext/ice/cpp/src/IceSSL/Instance.h +7 -12
  451. data/ext/ice/cpp/src/IceSSL/InstanceF.h +11 -12
  452. data/ext/ice/cpp/src/IceSSL/OpenSSLCertificateI.cpp +583 -0
  453. data/ext/ice/cpp/src/IceSSL/OpenSSLEngine.cpp +134 -115
  454. data/ext/ice/cpp/src/IceSSL/OpenSSLEngine.h +59 -0
  455. data/ext/ice/cpp/src/IceSSL/OpenSSLEngineF.h +27 -0
  456. data/ext/ice/cpp/src/IceSSL/OpenSSLPluginI.cpp +127 -0
  457. data/ext/ice/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +477 -182
  458. data/ext/ice/cpp/src/IceSSL/OpenSSLTransceiverI.h +32 -26
  459. data/ext/ice/cpp/src/IceSSL/OpenSSLUtil.cpp +286 -0
  460. data/ext/ice/cpp/src/IceSSL/OpenSSLUtil.h +58 -0
  461. data/ext/ice/cpp/src/IceSSL/PluginI.cpp +71 -46
  462. data/ext/ice/cpp/src/IceSSL/PluginI.h +13 -23
  463. data/ext/ice/cpp/src/IceSSL/RFC2253.cpp +9 -60
  464. data/ext/ice/cpp/src/IceSSL/RFC2253.h +7 -12
  465. data/ext/ice/cpp/src/IceSSL/SChannelCertificateI.cpp +580 -0
  466. data/ext/ice/cpp/src/IceSSL/SChannelEngine.cpp +523 -74
  467. data/ext/ice/cpp/src/IceSSL/SChannelEngine.h +123 -0
  468. data/ext/ice/cpp/src/IceSSL/SChannelEngineF.h +31 -0
  469. data/ext/ice/cpp/src/IceSSL/SChannelPluginI.cpp +73 -0
  470. data/ext/ice/cpp/src/IceSSL/SChannelTransceiverI.cpp +187 -221
  471. data/ext/ice/cpp/src/IceSSL/SChannelTransceiverI.h +24 -26
  472. data/ext/ice/cpp/src/IceSSL/SSLEngine.cpp +97 -94
  473. data/ext/ice/cpp/src/IceSSL/SSLEngine.h +26 -192
  474. data/ext/ice/cpp/src/IceSSL/SSLEngineF.h +4 -24
  475. data/ext/ice/cpp/src/IceSSL/SecureTransportCertificateI.cpp +868 -0
  476. data/ext/ice/cpp/src/IceSSL/SecureTransportEngine.cpp +69 -201
  477. data/ext/ice/cpp/src/IceSSL/SecureTransportEngine.h +59 -0
  478. data/ext/ice/cpp/src/IceSSL/SecureTransportEngineF.h +29 -0
  479. data/ext/ice/cpp/src/IceSSL/SecureTransportPluginI.cpp +75 -0
  480. data/ext/ice/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +174 -161
  481. data/ext/ice/cpp/src/IceSSL/SecureTransportTransceiverI.h +29 -33
  482. data/ext/ice/cpp/src/IceSSL/SecureTransportUtil.cpp +864 -0
  483. data/ext/ice/cpp/src/IceSSL/SecureTransportUtil.h +45 -0
  484. data/ext/ice/cpp/src/IceSSL/TrustManager.cpp +12 -22
  485. data/ext/ice/cpp/src/IceSSL/TrustManager.h +4 -9
  486. data/ext/ice/cpp/src/IceSSL/TrustManagerF.h +3 -8
  487. data/ext/ice/cpp/src/IceSSL/UWPCertificateI.cpp +266 -0
  488. data/ext/ice/cpp/src/IceSSL/UWPEngine.cpp +338 -0
  489. data/ext/ice/cpp/src/IceSSL/UWPEngine.h +41 -0
  490. data/ext/ice/cpp/src/IceSSL/UWPEngineF.h +26 -0
  491. data/ext/ice/cpp/src/IceSSL/UWPPluginI.cpp +89 -0
  492. data/ext/ice/cpp/src/IceSSL/UWPTransceiverI.cpp +383 -0
  493. data/ext/ice/cpp/src/IceSSL/UWPTransceiverI.h +71 -0
  494. data/ext/ice/cpp/src/IceSSL/Util.cpp +71 -1260
  495. data/ext/ice/cpp/src/IceSSL/Util.h +48 -142
  496. data/ext/ice/cpp/src/IceUtil/ConsoleUtil.cpp +157 -0
  497. data/ext/ice/cpp/src/IceUtil/ConvertUTF.cpp +22 -27
  498. data/ext/ice/cpp/src/IceUtil/ConvertUTF.h +34 -31
  499. data/ext/ice/cpp/src/IceUtil/CtrlCHandler.cpp +22 -36
  500. data/ext/ice/cpp/src/IceUtil/FileUtil.cpp +30 -126
  501. data/ext/ice/cpp/src/IceUtil/InputUtil.cpp +1 -6
  502. data/ext/ice/cpp/src/IceUtil/MutexProtocol.cpp +1 -6
  503. data/ext/ice/cpp/src/IceUtil/Options.cpp +20 -33
  504. data/ext/ice/cpp/src/IceUtil/OutputUtil.cpp +47 -21
  505. data/ext/ice/cpp/src/IceUtil/Random.cpp +15 -20
  506. data/ext/ice/cpp/src/IceUtil/RecMutex.cpp +4 -19
  507. data/ext/ice/cpp/src/IceUtil/Shared.cpp +8 -8
  508. data/ext/ice/cpp/src/IceUtil/StringConverter.cpp +501 -269
  509. data/ext/ice/cpp/src/IceUtil/StringUtil.cpp +582 -244
  510. data/ext/ice/cpp/src/IceUtil/ThreadException.cpp +37 -79
  511. data/ext/ice/cpp/src/IceUtil/Time.cpp +6 -11
  512. data/ext/ice/cpp/src/IceUtil/UUID.cpp +17 -22
  513. data/ext/ice/cpp/src/IceUtil/Unicode.cpp +97 -101
  514. data/ext/ice/cpp/src/IceUtil/Unicode.h +21 -40
  515. data/ext/ice/cpp/src/IceUtil/UtilException.cpp +839 -0
  516. data/ext/ice/cpp/src/Slice/CPlusPlusUtil.cpp +894 -234
  517. data/ext/ice/cpp/src/Slice/CPlusPlusUtil.h +72 -0
  518. data/ext/ice/cpp/src/Slice/Checksum.cpp +2 -7
  519. data/ext/ice/cpp/src/Slice/Checksum.h +21 -0
  520. data/ext/ice/cpp/src/Slice/FileTracker.cpp +25 -83
  521. data/ext/ice/cpp/{include → src}/Slice/FileTracker.h +9 -14
  522. data/ext/ice/cpp/src/Slice/Grammar.cpp +1981 -1944
  523. data/ext/ice/cpp/src/Slice/Grammar.h +39 -19
  524. data/ext/ice/cpp/src/Slice/GrammarUtil.h +14 -20
  525. data/ext/ice/cpp/src/Slice/JavaUtil.cpp +2752 -1948
  526. data/ext/ice/cpp/src/Slice/JavaUtil.h +398 -0
  527. data/ext/ice/cpp/src/Slice/MD5.cpp +1 -6
  528. data/ext/ice/cpp/src/Slice/MD5.h +1 -6
  529. data/ext/ice/cpp/src/Slice/MD5I.cpp +8 -1
  530. data/ext/ice/cpp/src/Slice/MD5I.h +1 -1
  531. data/ext/ice/cpp/src/Slice/PHPUtil.cpp +17 -20
  532. data/ext/ice/cpp/src/Slice/PHPUtil.h +36 -0
  533. data/ext/ice/cpp/src/Slice/Parser.cpp +1190 -426
  534. data/ext/ice/cpp/{include → src}/Slice/Parser.h +143 -91
  535. data/ext/ice/cpp/src/Slice/Preprocessor.cpp +67 -36
  536. data/ext/ice/cpp/{include → src}/Slice/Preprocessor.h +8 -18
  537. data/ext/ice/cpp/src/Slice/Python.cpp +218 -111
  538. data/ext/ice/cpp/src/Slice/PythonUtil.cpp +787 -699
  539. data/ext/ice/cpp/src/Slice/PythonUtil.h +70 -0
  540. data/ext/ice/cpp/src/Slice/Ruby.cpp +42 -43
  541. data/ext/ice/cpp/src/Slice/RubyUtil.cpp +175 -445
  542. data/ext/ice/cpp/{include → src}/Slice/RubyUtil.h +6 -11
  543. data/ext/ice/cpp/src/Slice/Scanner.cpp +390 -399
  544. data/ext/ice/cpp/src/Slice/{Util.cpp → SliceUtil.cpp} +36 -69
  545. data/ext/ice/cpp/src/Slice/StringLiteralUtil.cpp +456 -0
  546. data/ext/ice/cpp/src/Slice/Util.h +50 -0
  547. data/ice.gemspec +2 -9
  548. data/lib/Glacier2.rb +1 -6
  549. data/lib/Glacier2/Metrics.rb +6 -50
  550. data/lib/Glacier2/PermissionsVerifier.rb +23 -99
  551. data/lib/Glacier2/PermissionsVerifierF.rb +2 -7
  552. data/lib/Glacier2/Router.rb +31 -78
  553. data/lib/Glacier2/RouterF.rb +2 -7
  554. data/lib/Glacier2/SSLInfo.rb +3 -11
  555. data/lib/Glacier2/Session.rb +87 -311
  556. data/lib/Ice.rb +84 -58
  557. data/lib/Ice/BuiltinSequences.rb +3 -8
  558. data/lib/Ice/Communicator.rb +54 -61
  559. data/lib/Ice/CommunicatorF.rb +2 -7
  560. data/lib/Ice/Connection.rb +152 -166
  561. data/lib/Ice/ConnectionF.rb +2 -7
  562. data/lib/Ice/Current.rb +3 -15
  563. data/lib/Ice/Endpoint.rb +56 -137
  564. data/lib/Ice/EndpointF.rb +2 -7
  565. data/lib/Ice/EndpointTypes.rb +2 -11
  566. data/lib/Ice/FacetMap.rb +3 -8
  567. data/lib/Ice/Identity.rb +4 -12
  568. data/lib/Ice/ImplicitContext.rb +4 -38
  569. data/lib/Ice/ImplicitContextF.rb +2 -7
  570. data/lib/Ice/Instrumentation.rb +22 -279
  571. data/lib/Ice/InstrumentationF.rb +2 -7
  572. data/lib/Ice/LocalException.rb +94 -145
  573. data/lib/Ice/Locator.rb +50 -169
  574. data/lib/Ice/LocatorF.rb +2 -7
  575. data/lib/Ice/Logger.rb +4 -38
  576. data/lib/Ice/LoggerF.rb +2 -7
  577. data/lib/Ice/Metrics.rb +60 -420
  578. data/lib/Ice/ObjectAdapter.rb +29 -0
  579. data/lib/Ice/ObjectAdapterF.rb +2 -7
  580. data/lib/Ice/ObjectFactory.rb +4 -34
  581. data/lib/Ice/Plugin.rb +6 -64
  582. data/lib/Ice/PluginF.rb +2 -7
  583. data/lib/Ice/Process.rb +15 -56
  584. data/lib/Ice/ProcessF.rb +2 -7
  585. data/lib/Ice/Properties.rb +4 -45
  586. data/lib/Ice/PropertiesAdmin.rb +18 -60
  587. data/lib/Ice/PropertiesF.rb +2 -7
  588. data/lib/Ice/RemoteLogger.rb +33 -119
  589. data/lib/Ice/Router.rb +28 -105
  590. data/lib/Ice/RouterF.rb +2 -7
  591. data/lib/Ice/ServantLocator.rb +26 -0
  592. data/lib/Ice/ServantLocatorF.rb +24 -0
  593. data/lib/Ice/SliceChecksumDict.rb +2 -7
  594. data/lib/Ice/ValueFactory.rb +28 -0
  595. data/lib/Ice/Version.rb +4 -15
  596. data/lib/IceBox.rb +1 -6
  597. data/lib/IceBox/IceBox.rb +43 -152
  598. data/lib/IceGrid.rb +1 -9
  599. data/lib/IceGrid/Admin.rb +550 -431
  600. data/lib/IceGrid/Descriptor.rb +61 -533
  601. data/lib/IceGrid/Exception.rb +23 -49
  602. data/lib/IceGrid/FileParser.rb +13 -54
  603. data/lib/IceGrid/PluginFacade.rb +35 -0
  604. data/lib/IceGrid/Registry.rb +150 -62
  605. data/lib/IceGrid/Session.rb +24 -68
  606. data/lib/IceGrid/UserAccountMapper.rb +13 -54
  607. data/lib/IcePatch2.rb +1 -6
  608. data/lib/IcePatch2/FileInfo.rb +4 -15
  609. data/lib/IcePatch2/FileServer.rb +32 -80
  610. data/lib/IceStorm.rb +1 -6
  611. data/lib/IceStorm/IceStorm.rb +78 -210
  612. data/lib/IceStorm/Metrics.rb +10 -93
  613. data/slice/Glacier2/Metrics.ice +20 -10
  614. data/slice/Glacier2/PermissionsVerifier.ice +19 -12
  615. data/slice/Glacier2/PermissionsVerifierF.ice +16 -9
  616. data/slice/Glacier2/Router.ice +19 -13
  617. data/slice/Glacier2/RouterF.ice +16 -9
  618. data/slice/Glacier2/SSLInfo.ice +17 -10
  619. data/slice/Glacier2/Session.ice +24 -18
  620. data/slice/Ice/BuiltinSequences.ice +18 -9
  621. data/slice/Ice/Communicator.ice +180 -64
  622. data/slice/Ice/CommunicatorF.ice +18 -9
  623. data/slice/Ice/Connection.ice +208 -75
  624. data/slice/Ice/ConnectionF.ice +18 -9
  625. data/slice/Ice/Current.ice +37 -28
  626. data/slice/Ice/Endpoint.ice +73 -21
  627. data/slice/Ice/EndpointF.ice +19 -10
  628. data/slice/Ice/EndpointTypes.ice +21 -13
  629. data/slice/Ice/FacetMap.ice +19 -10
  630. data/slice/Ice/Identity.ice +24 -10
  631. data/slice/Ice/ImplicitContext.ice +41 -33
  632. data/slice/Ice/ImplicitContextF.ice +17 -9
  633. data/slice/Ice/Instrumentation.ice +37 -30
  634. data/slice/Ice/InstrumentationF.ice +19 -10
  635. data/slice/Ice/LocalException.ice +118 -112
  636. data/slice/Ice/Locator.ice +28 -21
  637. data/slice/Ice/LocatorF.ice +18 -9
  638. data/slice/Ice/Logger.ice +26 -18
  639. data/slice/Ice/LoggerF.ice +18 -9
  640. data/slice/Ice/Metrics.ice +42 -30
  641. data/slice/Ice/ObjectAdapter.ice +88 -53
  642. data/slice/Ice/ObjectAdapterF.ice +18 -9
  643. data/slice/Ice/ObjectFactory.ice +28 -17
  644. data/slice/Ice/Plugin.ice +25 -13
  645. data/slice/Ice/PluginF.ice +22 -9
  646. data/slice/Ice/Process.ice +20 -11
  647. data/slice/Ice/ProcessF.ice +18 -9
  648. data/slice/Ice/Properties.ice +42 -28
  649. data/slice/Ice/PropertiesAdmin.ice +20 -10
  650. data/slice/Ice/PropertiesF.ice +18 -9
  651. data/slice/Ice/RemoteLogger.ice +23 -19
  652. data/slice/Ice/Router.ice +28 -13
  653. data/slice/Ice/RouterF.ice +18 -9
  654. data/slice/Ice/ServantLocator.ice +40 -29
  655. data/slice/Ice/ServantLocatorF.ice +18 -9
  656. data/slice/Ice/SliceChecksumDict.ice +18 -9
  657. data/slice/Ice/ValueFactory.ice +132 -0
  658. data/slice/Ice/Version.ice +20 -10
  659. data/slice/IceBT/ConnectionInfo.ice +58 -0
  660. data/slice/IceBT/EndpointInfo.ice +56 -0
  661. data/slice/IceBT/Types.ice +44 -0
  662. data/slice/IceBox/IceBox.ice +45 -27
  663. data/slice/IceDiscovery/IceDiscovery.ice +75 -10
  664. data/slice/IceGrid/Admin.ice +410 -44
  665. data/slice/IceGrid/Descriptor.ice +47 -34
  666. data/slice/IceGrid/Exception.ice +43 -32
  667. data/slice/IceGrid/FileParser.ice +21 -12
  668. data/slice/IceGrid/PluginFacade.ice +26 -18
  669. data/slice/IceGrid/Registry.ice +150 -21
  670. data/slice/IceGrid/Session.ice +25 -17
  671. data/slice/IceGrid/UserAccountMapper.ice +23 -14
  672. data/slice/IceIAP/ConnectionInfo.ice +73 -0
  673. data/slice/IceIAP/EndpointInfo.ice +67 -0
  674. data/slice/IceLocatorDiscovery/IceLocatorDiscovery.ice +19 -12
  675. data/slice/IcePatch2/FileInfo.ice +19 -13
  676. data/slice/IcePatch2/FileServer.ice +27 -18
  677. data/slice/IceSSL/ConnectionInfo.ice +27 -23
  678. data/slice/IceSSL/ConnectionInfoF.ice +30 -0
  679. data/slice/IceSSL/EndpointInfo.ice +21 -36
  680. data/slice/IceStorm/IceStorm.ice +33 -24
  681. data/slice/IceStorm/Metrics.ice +19 -11
  682. metadata +148 -120
  683. data/ext/ObjectFactory.cpp +0 -140
  684. data/ext/ObjectFactory.h +0 -50
  685. data/ext/ice/cpp/include/Ice/ACMF.h +0 -30
  686. data/ext/ice/cpp/include/Ice/BasicStream.h +0 -1335
  687. data/ext/ice/cpp/include/Ice/BuiltinSequences.h +0 -82
  688. data/ext/ice/cpp/include/Ice/Communicator.h +0 -200
  689. data/ext/ice/cpp/include/Ice/Connection.h +0 -497
  690. data/ext/ice/cpp/include/Ice/ConnectionF.h +0 -74
  691. data/ext/ice/cpp/include/Ice/ConnectionFactoryF.h +0 -30
  692. data/ext/ice/cpp/include/Ice/Current.h +0 -102
  693. data/ext/ice/cpp/include/Ice/DefaultObjectFactory.h +0 -48
  694. data/ext/ice/cpp/include/Ice/DeprecatedStringConverter.h +0 -62
  695. data/ext/ice/cpp/include/Ice/Endpoint.h +0 -341
  696. data/ext/ice/cpp/include/Ice/EndpointF.h +0 -93
  697. data/ext/ice/cpp/include/Ice/EndpointTypes.h +0 -82
  698. data/ext/ice/cpp/include/Ice/Identity.h +0 -168
  699. data/ext/ice/cpp/include/Ice/ImplicitContext.h +0 -102
  700. data/ext/ice/cpp/include/Ice/Instrumentation.h +0 -365
  701. data/ext/ice/cpp/include/Ice/InstrumentationF.h +0 -75
  702. data/ext/ice/cpp/include/Ice/LocalException.h +0 -1030
  703. data/ext/ice/cpp/include/Ice/Locator.h +0 -2193
  704. data/ext/ice/cpp/include/Ice/LocatorF.h +0 -93
  705. data/ext/ice/cpp/include/Ice/Logger.h +0 -100
  706. data/ext/ice/cpp/include/Ice/Metrics.h +0 -2974
  707. data/ext/ice/cpp/include/Ice/ObjectAdapter.h +0 -168
  708. data/ext/ice/cpp/include/Ice/ObjectAdapterFactoryF.h +0 -26
  709. data/ext/ice/cpp/include/Ice/ObjectFactory.h +0 -92
  710. data/ext/ice/cpp/include/Ice/ObjectFactoryF.h +0 -66
  711. data/ext/ice/cpp/include/Ice/ObjectFactoryManagerF.h +0 -26
  712. data/ext/ice/cpp/include/Ice/Outgoing.h +0 -225
  713. data/ext/ice/cpp/include/Ice/Plugin.h +0 -125
  714. data/ext/ice/cpp/include/Ice/PluginF.h +0 -70
  715. data/ext/ice/cpp/include/Ice/Process.h +0 -574
  716. data/ext/ice/cpp/include/Ice/ProcessF.h +0 -83
  717. data/ext/ice/cpp/include/Ice/Properties.h +0 -136
  718. data/ext/ice/cpp/include/Ice/PropertiesAdmin.h +0 -830
  719. data/ext/ice/cpp/include/Ice/PropertiesF.h +0 -87
  720. data/ext/ice/cpp/include/Ice/RemoteLogger.h +0 -1500
  721. data/ext/ice/cpp/include/Ice/Router.h +0 -1159
  722. data/ext/ice/cpp/include/Ice/RouterF.h +0 -83
  723. data/ext/ice/cpp/include/Ice/ServantLocator.h +0 -96
  724. data/ext/ice/cpp/include/Ice/Stream.h +0 -447
  725. data/ext/ice/cpp/include/Ice/StreamF.h +0 -30
  726. data/ext/ice/cpp/include/Ice/Version.h +0 -262
  727. data/ext/ice/cpp/include/IceSSL/ConnectionInfo.h +0 -158
  728. data/ext/ice/cpp/include/IceSSL/EndpointInfo.h +0 -142
  729. data/ext/ice/cpp/include/IceUtil/AbstractMutex.h +0 -119
  730. data/ext/ice/cpp/include/IceUtil/Cache.h +0 -362
  731. data/ext/ice/cpp/include/IceUtil/IconvStringConverter.h +0 -302
  732. data/ext/ice/cpp/include/IceUtil/SHA1.h +0 -47
  733. data/ext/ice/cpp/include/Slice/CPlusPlusUtil.h +0 -65
  734. data/ext/ice/cpp/include/Slice/Checksum.h +0 -26
  735. data/ext/ice/cpp/include/Slice/CsUtil.h +0 -92
  736. data/ext/ice/cpp/include/Slice/DotNetNames.h +0 -34
  737. data/ext/ice/cpp/include/Slice/JavaUtil.h +0 -279
  738. data/ext/ice/cpp/include/Slice/ObjCUtil.h +0 -127
  739. data/ext/ice/cpp/include/Slice/PHPUtil.h +0 -50
  740. data/ext/ice/cpp/include/Slice/PythonUtil.h +0 -64
  741. data/ext/ice/cpp/include/Slice/Util.h +0 -56
  742. data/ext/ice/cpp/src/Ice/BasicStream.cpp +0 -3428
  743. data/ext/ice/cpp/src/Ice/DeprecatedStringConverter.cpp +0 -62
  744. data/ext/ice/cpp/src/Ice/ObjectFactoryF.cpp +0 -44
  745. data/ext/ice/cpp/src/Ice/ObjectFactoryManager.cpp +0 -139
  746. data/ext/ice/cpp/src/Ice/ObjectFactoryManager.h +0 -43
  747. data/ext/ice/cpp/src/Ice/Outgoing.cpp +0 -694
  748. data/ext/ice/cpp/src/Ice/Stream.cpp +0 -53
  749. data/ext/ice/cpp/src/Ice/StreamI.cpp +0 -832
  750. data/ext/ice/cpp/src/Ice/StreamI.h +0 -198
  751. data/ext/ice/cpp/src/IceSSL/Certificate.cpp +0 -1336
  752. data/ext/ice/cpp/src/IceUtil/ArgVector.cpp +0 -64
  753. data/ext/ice/cpp/src/IceUtil/ArgVector.h +0 -41
  754. data/ext/ice/cpp/src/IceUtil/Exception.cpp +0 -792
  755. data/ext/ice/cpp/src/IceUtil/FileUtil.h +0 -185
  756. data/ext/ice/cpp/src/Slice/CsUtil.cpp +0 -2660
  757. data/ext/ice/cpp/src/Slice/DotNetNames.cpp +0 -146
  758. data/ext/ice/cpp/src/Slice/ObjCUtil.cpp +0 -1310
  759. data/lib/Ice/ObjectFactoryF.rb +0 -29
  760. data/lib/IceGrid/Locator.rb +0 -106
  761. data/lib/IceGrid/Observer.rb +0 -572
  762. data/lib/IceGrid/Query.rb +0 -169
  763. data/slice/Freeze/BackgroundSaveEvictor.ice +0 -111
  764. data/slice/Freeze/CatalogData.ice +0 -49
  765. data/slice/Freeze/Connection.ice +0 -121
  766. data/slice/Freeze/ConnectionF.ice +0 -20
  767. data/slice/Freeze/DB.ice +0 -37
  768. data/slice/Freeze/Evictor.ice +0 -346
  769. data/slice/Freeze/EvictorF.ice +0 -22
  770. data/slice/Freeze/EvictorStorage.ice +0 -72
  771. data/slice/Freeze/Exception.ice +0 -100
  772. data/slice/Freeze/Transaction.ice +0 -58
  773. data/slice/Freeze/TransactionalEvictor.ice +0 -50
  774. data/slice/Ice/ObjectFactoryF.ice +0 -21
  775. data/slice/IceGrid/Locator.ice +0 -57
  776. data/slice/IceGrid/Observer.ice +0 -395
  777. data/slice/IceGrid/Query.ice +0 -131
@@ -1,11 +1,6 @@
1
- // **********************************************************************
2
1
  //
3
- // Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
2
+ // Copyright (c) ZeroC, Inc. All rights reserved.
4
3
  //
5
- // This copy of Ice is licensed to you under the terms described in the
6
- // ICE_LICENSE file included in this distribution.
7
- //
8
- // **********************************************************************
9
4
 
10
5
  #include <Ice/MetricsAdminI.h>
11
6
 
@@ -23,7 +18,7 @@ using namespace Ice;
23
18
  using namespace IceInternal;
24
19
  using namespace IceMX;
25
20
 
26
- namespace
21
+ namespace
27
22
  {
28
23
 
29
24
  const string suffixes[] =
@@ -80,11 +75,11 @@ parseRule(const PropertiesPtr& properties, const string& name)
80
75
  {
81
76
  try
82
77
  {
83
- regexps.push_back(new MetricsMapI::RegExp(p->first.substr(name.length() + 1), p->second));
78
+ regexps.push_back(ICE_MAKE_SHARED(MetricsMapI::RegExp, p->first.substr(name.length() + 1), p->second));
84
79
  }
85
80
  catch(const std::exception&)
86
81
  {
87
- throw "invalid regular expression `" + p->second + "' for `" + p->first + "'";
82
+ throw invalid_argument("invalid regular expression `" + p->second + "' for `" + p->first + "'");
88
83
  }
89
84
  }
90
85
  return regexps;
@@ -99,10 +94,10 @@ MetricsMapI::RegExp::RegExp(const string& attribute, const string& regexp) : _at
99
94
  // No regexp support with MinGW, when MinGW C++11 mode is not experimental
100
95
  // we can use std::regex.
101
96
  //
102
- #elif !defined(ICE_CPP11_REGEXP)
97
+ #elif !defined(ICE_CPP11_COMPILER_REGEXP)
103
98
  if(regcomp(&_preg, regexp.c_str(), REG_EXTENDED | REG_NOSUB) != 0)
104
99
  {
105
- throw SyscallException(__FILE__, __LINE__);
100
+ throw SyscallException(__FILE__, __LINE__);
106
101
  }
107
102
  #else
108
103
  # if _MSC_VER < 1600
@@ -120,7 +115,7 @@ MetricsMapI::RegExp::~RegExp()
120
115
  // No regexp support with MinGW, when MinGW C++11 mode is not experimental
121
116
  // we can use std::regex.
122
117
  //
123
- #elif !defined(ICE_CPP11_REGEXP)
118
+ #elif !defined(ICE_CPP11_COMPILER_REGEXP)
124
119
  regfree(&_preg);
125
120
  #endif
126
121
  }
@@ -134,7 +129,7 @@ MetricsMapI::RegExp::match(const string& value)
134
129
  // we can use std::regex.
135
130
  //
136
131
  return false;
137
- #elif !defined(ICE_CPP11_REGEXP)
132
+ #elif !defined(ICE_CPP11_COMPILER_REGEXP)
138
133
  return regexec(&_preg, value.c_str(), 0, 0, 0) == 0;
139
134
  #else
140
135
  # if _MSC_VER < 1600
@@ -145,6 +140,11 @@ MetricsMapI::RegExp::match(const string& value)
145
140
  #endif
146
141
  }
147
142
 
143
+ MetricsMapI::~MetricsMapI()
144
+ {
145
+ // Out of line to avoid weak vtable
146
+ }
147
+
148
148
  MetricsMapI::MetricsMapI(const std::string& mapPrefix, const PropertiesPtr& properties) :
149
149
  _properties(properties->getPropertiesForPrefix(mapPrefix)),
150
150
  _retain(properties->getPropertyAsIntWithDefault(mapPrefix + "RetainDetached", 10)),
@@ -164,7 +164,7 @@ MetricsMapI::MetricsMapI(const std::string& mapPrefix, const PropertiesPtr& prop
164
164
  {
165
165
  groupByAttributes.push_back("");
166
166
  }
167
-
167
+
168
168
  for(string::const_iterator p = groupBy.begin(); p != groupBy.end(); ++p)
169
169
  {
170
170
  bool isAlphaNum = IceUtilInternal::isAlpha(*p) || IceUtilInternal::isDigit(*p) || *p == '.';
@@ -198,6 +198,11 @@ MetricsMapI::MetricsMapI(const std::string& mapPrefix, const PropertiesPtr& prop
198
198
  }
199
199
 
200
200
  MetricsMapI::MetricsMapI(const MetricsMapI& map) :
201
+ #if defined(ICE_CPP11_MAPPING)
202
+ std::enable_shared_from_this<MetricsMapI>(),
203
+ #elif defined(__GNUC__)
204
+ IceUtil::Shared(),
205
+ #endif
201
206
  _properties(map._properties),
202
207
  _groupByAttributes(map._groupByAttributes),
203
208
  _groupBySeparators(map._groupBySeparators),
@@ -213,6 +218,11 @@ MetricsMapI::getProperties() const
213
218
  return _properties;
214
219
  }
215
220
 
221
+ MetricsMapFactory::~MetricsMapFactory()
222
+ {
223
+ // Out of line to avoid weak vtable
224
+ }
225
+
216
226
  MetricsMapFactory::MetricsMapFactory(Updater* updater) : _updater(updater)
217
227
  {
218
228
  }
@@ -223,7 +233,7 @@ MetricsMapFactory::update()
223
233
  assert(_updater);
224
234
  _updater->update();
225
235
  }
226
-
236
+
227
237
  MetricsViewI::MetricsViewI(const string& name) : _name(name)
228
238
  {
229
239
  }
@@ -238,7 +248,7 @@ MetricsViewI::destroy()
238
248
  }
239
249
 
240
250
  bool
241
- MetricsViewI::addOrUpdateMap(const PropertiesPtr& properties, const string& mapName,
251
+ MetricsViewI::addOrUpdateMap(const PropertiesPtr& properties, const string& mapName,
242
252
  const MetricsMapFactoryPtr& factory, const ::Ice::LoggerPtr& logger)
243
253
  {
244
254
  const string viewPrefix = "IceMX.Metrics." + _name + ".";
@@ -305,11 +315,6 @@ MetricsViewI::addOrUpdateMap(const PropertiesPtr& properties, const string& mapN
305
315
  ::Ice::Warning warn(logger);
306
316
  warn << "unexpected exception while creating metrics map:\n" << ex;
307
317
  }
308
- catch(const string& msg)
309
- {
310
- ::Ice::Warning warn(logger);
311
- warn << msg;
312
- }
313
318
  return true;
314
319
  }
315
320
 
@@ -378,10 +383,10 @@ MetricsViewI::getMap(const string& mapName) const
378
383
  {
379
384
  return p->second;
380
385
  }
381
- return 0;
386
+ return ICE_NULLPTR;
382
387
  }
383
388
 
384
- MetricsAdminI::MetricsAdminI(const PropertiesPtr& properties, const LoggerPtr& logger) :
389
+ MetricsAdminI::MetricsAdminI(const PropertiesPtr& properties, const LoggerPtr& logger) :
385
390
  _logger(logger), _properties(properties)
386
391
  {
387
392
  updateViews();
@@ -439,23 +444,23 @@ MetricsAdminI::updateViews()
439
444
  map<string, MetricsViewIPtr>::const_iterator q = _views.find(viewName);
440
445
  if(q == _views.end())
441
446
  {
442
- q = views.insert(map<string, MetricsViewIPtr>::value_type(viewName, new MetricsViewI(viewName))).first;
447
+ q = views.insert(map<string, MetricsViewIPtr>::value_type(viewName, ICE_MAKE_SHARED(MetricsViewI, viewName))).first;
443
448
  }
444
449
  else
445
450
  {
446
451
  q = views.insert(make_pair(viewName, q->second)).first;
447
452
  }
448
453
 
449
- for(map<string, MetricsMapFactoryPtr>::const_iterator p = _factories.begin(); p != _factories.end(); ++p)
454
+ for(map<string, MetricsMapFactoryPtr>::const_iterator r = _factories.begin(); r != _factories.end(); ++r)
450
455
  {
451
- if(q->second->addOrUpdateMap(_properties, p->first, p->second, _logger))
456
+ if(q->second->addOrUpdateMap(_properties, r->first, r->second, _logger))
452
457
  {
453
- updatedMaps.insert(p->second);
458
+ updatedMaps.insert(r->second);
454
459
  }
455
460
  }
456
461
  }
457
462
  _views.swap(views);
458
-
463
+
459
464
  //
460
465
  // Go through removed views to collect maps to update.
461
466
  //
@@ -472,7 +477,7 @@ MetricsAdminI::updateViews()
472
477
  }
473
478
  }
474
479
  }
475
-
480
+
476
481
  //
477
482
  // Call the updaters to update the maps.
478
483
  //
@@ -523,13 +528,17 @@ MetricsAdminI::getMetricsViewNames(Ice::StringSeq& disabledViews, const Current&
523
528
 
524
529
  #else
525
530
  disabledViews.insert(disabledViews.end(), _disabledViews.begin(), _disabledViews.end());
526
- #endif
531
+ #endif
527
532
 
528
533
  return enabledViews;
529
534
  }
530
535
 
531
536
  void
537
+ #ifdef ICE_CPP11_MAPPING
538
+ MetricsAdminI::enableMetricsView(string viewName, const Current&)
539
+ #else
532
540
  MetricsAdminI::enableMetricsView(const string& viewName, const Current&)
541
+ #endif
533
542
  {
534
543
  {
535
544
  Lock sync(*this);
@@ -540,7 +549,11 @@ MetricsAdminI::enableMetricsView(const string& viewName, const Current&)
540
549
  }
541
550
 
542
551
  void
552
+ #ifdef ICE_CPP11_MAPPING
553
+ MetricsAdminI::disableMetricsView(string viewName, const Current&)
554
+ #else
543
555
  MetricsAdminI::disableMetricsView(const string& viewName, const Current&)
556
+ #endif
544
557
  {
545
558
  {
546
559
  Lock sync(*this);
@@ -551,7 +564,11 @@ MetricsAdminI::disableMetricsView(const string& viewName, const Current&)
551
564
  }
552
565
 
553
566
  MetricsView
567
+ #ifdef ICE_CPP11_MAPPING
568
+ MetricsAdminI::getMetricsView(string viewName, ::Ice::Long& timestamp, const Current&)
569
+ #else
554
570
  MetricsAdminI::getMetricsView(const string& viewName, ::Ice::Long& timestamp, const Current&)
571
+ #endif
555
572
  {
556
573
  Lock sync(*this);
557
574
  MetricsViewIPtr view = getMetricsView(viewName);
@@ -564,7 +581,11 @@ MetricsAdminI::getMetricsView(const string& viewName, ::Ice::Long& timestamp, co
564
581
  }
565
582
 
566
583
  MetricsFailuresSeq
584
+ #ifdef ICE_CPP11_MAPPING
585
+ MetricsAdminI::getMapMetricsFailures(string viewName, string map, const Current&)
586
+ #else
567
587
  MetricsAdminI::getMapMetricsFailures(const string& viewName, const string& map, const Current&)
588
+ #endif
568
589
  {
569
590
  Lock sync(*this);
570
591
  MetricsViewIPtr view = getMetricsView(viewName);
@@ -576,7 +597,11 @@ MetricsAdminI::getMapMetricsFailures(const string& viewName, const string& map,
576
597
  }
577
598
 
578
599
  MetricsFailures
600
+ #ifdef ICE_CPP11_MAPPING
601
+ MetricsAdminI::getMetricsFailures(string viewName, string map, string id, const Current&)
602
+ #else
579
603
  MetricsAdminI::getMetricsFailures(const string& viewName, const string& map, const string& id, const Current&)
604
+ #endif
580
605
  {
581
606
  Lock sync(*this);
582
607
  MetricsViewIPtr view = getMetricsView(viewName);
@@ -587,7 +612,7 @@ MetricsAdminI::getMetricsFailures(const string& viewName, const string& map, con
587
612
  return MetricsFailures();
588
613
  }
589
614
 
590
- vector<MetricsMapIPtr>
615
+ vector<MetricsMapIPtr>
591
616
  MetricsAdminI::getMaps(const string& mapName) const
592
617
  {
593
618
  Lock sync(*this);
@@ -619,12 +644,12 @@ MetricsAdminI::getMetricsView(const std::string& name)
619
644
  {
620
645
  throw UnknownMetricsView();
621
646
  }
622
- return 0;
647
+ return ICE_NULLPTR;
623
648
  }
624
649
  return p->second;
625
650
  }
626
651
 
627
- void
652
+ void
628
653
  MetricsAdminI::updated(const PropertyDict& props)
629
654
  {
630
655
  for(PropertyDict::const_iterator p = props.begin(); p != props.end(); ++p)
@@ -1,14 +1,8 @@
1
- // **********************************************************************
2
1
  //
3
- // Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
2
+ // Copyright (c) ZeroC, Inc. All rights reserved.
4
3
  //
5
- // This copy of Ice is licensed to you under the terms described in the
6
- // ICE_LICENSE file included in this distribution.
7
- //
8
- // **********************************************************************
9
4
 
10
5
  #include <Ice/MetricsObserverI.h>
11
6
 
12
7
  #include <Ice/Connection.h>
13
8
  #include <Ice/Endpoint.h>
14
-
@@ -1,11 +1,6 @@
1
- // **********************************************************************
2
1
  //
3
- // Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
2
+ // Copyright (c) ZeroC, Inc. All rights reserved.
4
3
  //
5
- // This copy of Ice is licensed to you under the terms described in the
6
- // ICE_LICENSE file included in this distribution.
7
- //
8
- // **********************************************************************
9
4
 
10
5
  //
11
6
  // The following is required on HP-UX in order to bring in
@@ -21,17 +16,22 @@
21
16
  #include <Ice/Network.h>
22
17
  #include <Ice/NetworkProxy.h>
23
18
  #include <IceUtil/StringUtil.h>
24
- #include <IceUtil/StringConverter.h>
19
+ #include <Ice/StringConverter.h>
25
20
  #include <Ice/LocalException.h>
26
21
  #include <Ice/ProtocolInstance.h> // For setTcpBufSize
27
22
  #include <Ice/Properties.h> // For setTcpBufSize
28
23
  #include <Ice/LoggerUtil.h> // For setTcpBufSize
29
24
  #include <Ice/Buffer.h>
30
25
  #include <IceUtil/Random.h>
26
+ #include <functional>
27
+
28
+ // TODO: fix this warning
29
+ #if defined(_MSC_VER)
30
+ # pragma warning(disable:4244) // 'argument': conversion from 'int' to 'u_short', possible loss of data
31
+ #endif
31
32
 
32
- #if defined(ICE_OS_WINRT)
33
+ #if defined(ICE_OS_UWP)
33
34
  # include <IceUtil/InputUtil.h>
34
- # include <IceUtil/CountDownLatch.h>
35
35
  #elif defined(_WIN32)
36
36
  # include <winsock2.h>
37
37
  # include <ws2tcpip.h>
@@ -52,6 +52,10 @@
52
52
  # include <sys/sockio.h>
53
53
  #endif
54
54
 
55
+ #if defined(__GNUC__) && (__GNUC__ < 5)
56
+ # pragma GCC diagnostic ignored "-Wmissing-field-initializers"
57
+ #endif
58
+
55
59
  #if defined(_WIN32)
56
60
  # ifndef SIO_LOOPBACK_FAST_PATH
57
61
  # define SIO_LOOPBACK_FAST_PATH _WSAIOW(IOC_VENDOR,16)
@@ -72,12 +76,12 @@ extern "C"
72
76
  }
73
77
  #endif
74
78
 
75
-
76
79
  using namespace std;
77
80
  using namespace Ice;
78
81
  using namespace IceInternal;
79
82
 
80
- #ifdef ICE_OS_WINRT
83
+ #ifdef ICE_OS_UWP
84
+ using namespace Concurrency;
81
85
  using namespace Platform;
82
86
  using namespace Windows::Foundation;
83
87
  using namespace Windows::Foundation::Collections;
@@ -87,40 +91,78 @@ using namespace Windows::Networking::Sockets;
87
91
  using namespace Windows::Networking::Connectivity;
88
92
  #endif
89
93
 
94
+ #ifdef _WIN32
95
+ int
96
+ IceInternal::getSystemErrno()
97
+ {
98
+ return GetLastError();
99
+ }
100
+ #else
101
+ int
102
+ IceInternal::getSystemErrno()
103
+ {
104
+ return errno;
105
+ }
106
+ #endif
107
+
90
108
  namespace
91
109
  {
92
110
 
93
- #ifndef ICE_OS_WINRT
94
- struct AddressIsIPv6 : public unary_function<Address, bool>
111
+ struct AddressCompare
95
112
  {
96
113
  public:
97
114
 
98
115
  bool
99
- operator()(const Address& ss) const
116
+ operator()(const Address& lhs, const Address& rhs) const
100
117
  {
101
- return ss.saStorage.ss_family == AF_INET6;
118
+ return compareAddress(lhs, rhs) < 0;
102
119
  }
103
120
  };
104
121
 
105
- struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t>
122
+ #ifndef ICE_OS_UWP
123
+
124
+ # ifndef ICE_CPP11_COMPILER
125
+
126
+ struct AddressIsIPv6 : public unary_function<Address, bool>
106
127
  {
107
- ptrdiff_t operator()(ptrdiff_t d)
128
+ public:
129
+
130
+ bool
131
+ operator()(const Address& ss) const
108
132
  {
109
- return IceUtilInternal::random(static_cast<int>(d));
133
+ return ss.saStorage.ss_family == AF_INET6;
110
134
  }
111
135
  };
136
+ # endif
112
137
 
113
138
  void
114
139
  sortAddresses(vector<Address>& addrs, ProtocolSupport protocol, Ice::EndpointSelectionType selType, bool preferIPv6)
115
140
  {
116
- if(selType == Ice::Random)
141
+ if(selType == Ice::ICE_ENUM(EndpointSelectionType, Random))
117
142
  {
118
- RandomNumberGenerator rng;
119
- random_shuffle(addrs.begin(), addrs.end(), rng);
143
+ IceUtilInternal::shuffle(addrs.begin(), addrs.end());
120
144
  }
121
145
 
122
146
  if(protocol == EnableBoth)
123
147
  {
148
+ #ifdef ICE_CPP11_COMPILER
149
+ if(preferIPv6)
150
+ {
151
+ stable_partition(addrs.begin(), addrs.end(),
152
+ [](const Address& ss)
153
+ {
154
+ return ss.saStorage.ss_family == AF_INET6;
155
+ });
156
+ }
157
+ else
158
+ {
159
+ stable_partition(addrs.begin(), addrs.end(),
160
+ [](const Address& ss)
161
+ {
162
+ return ss.saStorage.ss_family != AF_INET6;
163
+ });
164
+ }
165
+ #else
124
166
  if(preferIPv6)
125
167
  {
126
168
  stable_partition(addrs.begin(), addrs.end(), AddressIsIPv6());
@@ -129,6 +171,7 @@ sortAddresses(vector
& addrs, ProtocolSupport protocol, Ice::EndpointSel
129
171
  {
130
172
  stable_partition(addrs.begin(), addrs.end(), not1(AddressIsIPv6()));
131
173
  }
174
+ #endif
132
175
  }
133
176
  }
134
177
 
@@ -139,9 +182,7 @@ setTcpNoDelay(SOCKET fd)
139
182
  if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char*>(&flag), int(sizeof(int))) == SOCKET_ERROR)
140
183
  {
141
184
  closeSocketNoThrow(fd);
142
- SocketException ex(__FILE__, __LINE__);
143
- ex.error = getSocketErrno();
144
- throw ex;
185
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
145
186
  }
146
187
  }
147
188
 
@@ -152,19 +193,37 @@ setKeepAlive(SOCKET fd)
152
193
  if(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, reinterpret_cast<char*>(&flag), int(sizeof(int))) == SOCKET_ERROR)
153
194
  {
154
195
  closeSocketNoThrow(fd);
155
- SocketException ex(__FILE__, __LINE__);
156
- ex.error = getSocketErrno();
157
- throw ex;
196
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
158
197
  }
159
198
  }
160
199
  #endif
161
200
 
162
- #ifdef ICE_OS_WINRT
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
163
224
  SOCKET
164
225
  createSocketImpl(bool udp, int)
165
226
  {
166
- SOCKET fd;
167
-
168
227
  if(udp)
169
228
  {
170
229
  return ref new DatagramSocket();
@@ -176,8 +235,6 @@ createSocketImpl(bool udp, int)
176
235
  socket->Control->NoDelay = true;
177
236
  return socket;
178
237
  }
179
-
180
- return fd;
181
238
  }
182
239
  #else
183
240
  SOCKET
@@ -195,9 +252,7 @@ createSocketImpl(bool udp, int family)
195
252
 
196
253
  if(fd == INVALID_SOCKET)
197
254
  {
198
- SocketException ex(__FILE__, __LINE__);
199
- ex.error = getSocketErrno();
200
- throw ex;
255
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
201
256
  }
202
257
 
203
258
  if(!udp)
@@ -205,7 +260,7 @@ createSocketImpl(bool udp, int family)
205
260
  setTcpNoDelay(fd);
206
261
  setKeepAlive(fd);
207
262
 
208
- #if defined(_WIN32) && !defined(ICE_OS_WINRT)
263
+ #if defined(_WIN32) && !defined(ICE_OS_UWP)
209
264
  //
210
265
  // FIX: the fast path loopback appears to cause issues with
211
266
  // connection closure when it's enabled. Sometime, a peer
@@ -222,9 +277,9 @@ createSocketImpl(bool udp, int family)
222
277
  }
223
278
  #endif
224
279
 
225
- #ifndef ICE_OS_WINRT
280
+ #ifndef ICE_OS_UWP
226
281
  vector<Address>
227
- getLocalAddresses(ProtocolSupport protocol, bool includeLoopback)
282
+ getLocalAddresses(ProtocolSupport protocol, bool includeLoopback, bool singleAddressPerInterface)
228
283
  {
229
284
  vector<Address> result;
230
285
 
@@ -243,17 +298,21 @@ getLocalAddresses(ProtocolSupport protocol, bool includeLoopback)
243
298
  break;
244
299
  }
245
300
 
246
- DWORD size;
247
- DWORD rv = GetAdaptersAddresses(family, 0, NULL, NULL, &size);
248
- if (rv == ERROR_BUFFER_OVERFLOW)
301
+ DWORD size = 0;
302
+ DWORD rv = GetAdaptersAddresses(family, 0, ICE_NULLPTR, ICE_NULLPTR, &size);
303
+ if(rv == ERROR_BUFFER_OVERFLOW)
249
304
  {
250
305
  PIP_ADAPTER_ADDRESSES adapter_addresses = (PIP_ADAPTER_ADDRESSES) malloc(size);
251
- rv = GetAdaptersAddresses(family, 0, NULL, adapter_addresses, &size);
252
- if (rv == ERROR_SUCCESS)
306
+ rv = GetAdaptersAddresses(family, 0, ICE_NULLPTR, adapter_addresses, &size);
307
+ if(rv == ERROR_SUCCESS)
253
308
  {
254
- for (PIP_ADAPTER_ADDRESSES aa = adapter_addresses; aa != NULL; aa = aa->Next)
309
+ for(PIP_ADAPTER_ADDRESSES aa = adapter_addresses; aa != ICE_NULLPTR; aa = aa->Next)
255
310
  {
256
- for (PIP_ADAPTER_UNICAST_ADDRESS ua = aa->FirstUnicastAddress; ua != NULL; ua = ua->Next)
311
+ if(aa->OperStatus != IfOperStatusUp)
312
+ {
313
+ continue;
314
+ }
315
+ for(PIP_ADAPTER_UNICAST_ADDRESS ua = aa->FirstUnicastAddress; ua != ICE_NULLPTR; ua = ua->Next)
257
316
  {
258
317
  Address addr;
259
318
  memcpy(&addr.saStorage, ua->Address.lpSockaddr, ua->Address.iSockaddrLength);
@@ -263,6 +322,10 @@ getLocalAddresses(ProtocolSupport protocol, bool includeLoopback)
263
322
  (includeLoopback || addr.saIn.sin_addr.s_addr != htonl(INADDR_LOOPBACK)))
264
323
  {
265
324
  result.push_back(addr);
325
+ if(singleAddressPerInterface)
326
+ {
327
+ break; // One address is enough for each interface.
328
+ }
266
329
  }
267
330
  }
268
331
  else if(addr.saStorage.ss_family == AF_INET6 && protocol != EnableIPv4)
@@ -271,6 +334,10 @@ getLocalAddresses(ProtocolSupport protocol, bool includeLoopback)
271
334
  (includeLoopback || !IN6_IS_ADDR_LOOPBACK(&addr.saIn6.sin6_addr)))
272
335
  {
273
336
  result.push_back(addr);
337
+ if(singleAddressPerInterface)
338
+ {
339
+ break; // One address is enough for each interface.
340
+ }
274
341
  }
275
342
  }
276
343
  }
@@ -283,12 +350,11 @@ getLocalAddresses(ProtocolSupport protocol, bool includeLoopback)
283
350
  struct ifaddrs* ifap;
284
351
  if(::getifaddrs(&ifap) == SOCKET_ERROR)
285
352
  {
286
- SocketException ex(__FILE__, __LINE__);
287
- ex.error = getSocketErrno();
288
- throw ex;
353
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
289
354
  }
290
355
 
291
356
  struct ifaddrs* curr = ifap;
357
+ set<string> interfaces;
292
358
  while(curr != 0)
293
359
  {
294
360
  if(curr->ifa_addr && (includeLoopback || !(curr->ifa_flags & IFF_LOOPBACK)))
@@ -299,7 +365,11 @@ getLocalAddresses(ProtocolSupport protocol, bool includeLoopback)
299
365
  memcpy(&addr.saStorage, curr->ifa_addr, sizeof(sockaddr_in));
300
366
  if(addr.saIn.sin_addr.s_addr != 0)
301
367
  {
302
- result.push_back(addr);
368
+ if(!singleAddressPerInterface || interfaces.find(curr->ifa_name) == interfaces.end())
369
+ {
370
+ result.push_back(addr);
371
+ interfaces.insert(curr->ifa_name);
372
+ }
303
373
  }
304
374
  }
305
375
  else if(curr->ifa_addr->sa_family == AF_INET6 && protocol != EnableIPv4)
@@ -308,7 +378,11 @@ getLocalAddresses(ProtocolSupport protocol, bool includeLoopback)
308
378
  memcpy(&addr.saStorage, curr->ifa_addr, sizeof(sockaddr_in6));
309
379
  if(!IN6_IS_ADDR_UNSPECIFIED(&addr.saIn6.sin6_addr))
310
380
  {
311
- result.push_back(addr);
381
+ if(!singleAddressPerInterface || interfaces.find(curr->ifa_name) == interfaces.end())
382
+ {
383
+ result.push_back(addr);
384
+ interfaces.insert(curr->ifa_name);
385
+ }
312
386
  }
313
387
  }
314
388
  }
@@ -352,9 +426,7 @@ getLocalAddresses(ProtocolSupport protocol, bool includeLoopback)
352
426
  {
353
427
  free(ifc.ifc_buf);
354
428
  closeSocketNoThrow(fd);
355
- SocketException ex(__FILE__, __LINE__);
356
- ex.error = getSocketErrno();
357
- throw ex;
429
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
358
430
  }
359
431
  else if(ifc.ifc_len == old_ifc_len)
360
432
  {
@@ -375,54 +447,41 @@ getLocalAddresses(ProtocolSupport protocol, bool includeLoopback)
375
447
 
376
448
  numaddrs = ifc.ifc_len / static_cast<int>(sizeof(struct ifreq));
377
449
  struct ifreq* ifr = ifc.ifc_req;
378
- for(int i = 0; i < numaddrs; ++i)
450
+ set<string> interfaces;
451
+ for(int j = 0; j < numaddrs; ++j)
379
452
  {
380
- if(!(ifr[i].ifr_flags & IFF_LOOPBACK)) // Don't include loopback interface addresses
453
+ if(!(ifr[j].ifr_flags & IFF_LOOPBACK)) // Don't include loopback interface addresses
381
454
  {
382
455
  //
383
456
  // On Solaris the above Loopback check does not always work so we double
384
457
  // check the address below. Solaris also returns duplicate entries that need
385
458
  // to be filtered out.
386
459
  //
387
- if(ifr[i].ifr_addr.sa_family == AF_INET && protocol != EnableIPv6)
460
+ if(ifr[j].ifr_addr.sa_family == AF_INET && protocol != EnableIPv6)
388
461
  {
389
462
  Address addr;
390
- memcpy(&addr.saStorage, &ifr[i].ifr_addr, sizeof(sockaddr_in));
463
+ memcpy(&addr.saStorage, &ifr[j].ifr_addr, sizeof(sockaddr_in));
391
464
  if(addr.saIn.sin_addr.s_addr != 0 &&
392
465
  (includeLoopback || addr.saIn.sin_addr.s_addr != htonl(INADDR_LOOPBACK)))
393
466
  {
394
- unsigned int j;
395
- for(j = 0; j < result.size(); ++j)
396
- {
397
- if(compareAddress(addr, result[j]) == 0)
398
- {
399
- break;
400
- }
401
- }
402
- if(j == result.size())
467
+ if(!singleAddressPerInterface || interfaces.find(ifr[j].ifr_name) == interfaces.end())
403
468
  {
404
469
  result.push_back(addr);
470
+ interfaces.insert(ifr[j].ifr_name);
405
471
  }
406
472
  }
407
473
  }
408
- else if(ifr[i].ifr_addr.sa_family == AF_INET6 && protocol != EnableIPv4)
474
+ else if(ifr[j].ifr_addr.sa_family == AF_INET6 && protocol != EnableIPv4)
409
475
  {
410
476
  Address addr;
411
- memcpy(&addr.saStorage, &ifr[i].ifr_addr, sizeof(sockaddr_in6));
477
+ memcpy(&addr.saStorage, &ifr[j].ifr_addr, sizeof(sockaddr_in6));
412
478
  if(!IN6_IS_ADDR_UNSPECIFIED(&addr.saIn6.sin6_addr) &&
413
479
  (includeLoopback || !IN6_IS_ADDR_LOOPBACK(&addr.saIn6.sin6_addr)))
414
480
  {
415
- unsigned int j;
416
- for(j = 0; j < result.size(); ++j)
417
- {
418
- if(compareAddress(addr, result[j]) == 0)
419
- {
420
- break;
421
- }
422
- }
423
- if(j == result.size())
481
+ if(!singleAddressPerInterface || interfaces.find(ifr[j].ifr_name) == interfaces.end())
424
482
  {
425
483
  result.push_back(addr);
484
+ interfaces.insert(ifr[j].ifr_name);
426
485
  }
427
486
  }
428
487
  }
@@ -432,17 +491,31 @@ getLocalAddresses(ProtocolSupport protocol, bool includeLoopback)
432
491
  }
433
492
  #endif
434
493
 
494
+ //
495
+ // Remove potential duplicates from the result.
496
+ //
497
+ set<Address, AddressCompare> seen;
498
+ vector<Address> tmp;
499
+ tmp.swap(result);
500
+ for(vector<Address>::const_iterator p = tmp.begin(); p != tmp.end(); ++p)
501
+ {
502
+ if(seen.find(*p) == seen.end())
503
+ {
504
+ result.push_back(*p);
505
+ seen.insert(*p);
506
+ }
507
+ }
435
508
  return result;
436
509
  }
437
510
 
438
511
  bool
439
512
  isLinklocal(const Address& addr)
440
513
  {
441
- if (addr.saStorage.ss_family == AF_INET6)
514
+ if(addr.saStorage.ss_family == AF_INET6)
442
515
  {
443
516
  return IN6_IS_ADDR_LINKLOCAL(&addr.saIn6.sin6_addr);
444
517
  }
445
- else if (addr.saStorage.ss_family == AF_INET)
518
+ else if(addr.saStorage.ss_family == AF_INET)
446
519
  {
447
520
  // Check for 169.254.X.X in network order
448
521
  return (addr.saIn.sin_addr.s_addr & 0xFF) == 169 && ((addr.saIn.sin_addr.s_addr & 0xFF00)>>8) == 254;
@@ -453,58 +526,66 @@ isLinklocal(const Address& addr)
453
526
  bool
454
527
  isWildcard(const string& host, ProtocolSupport protocol, bool& ipv4)
455
528
  {
456
- try
529
+ Address addr = getAddressForServer(host, 0, protocol, true, false);
530
+ if(addr.saStorage.ss_family == AF_INET)
457
531
  {
458
- Address addr = getAddressForServer(host, 0, protocol, true);
459
- if(addr.saStorage.ss_family == AF_INET)
532
+ if(addr.saIn.sin_addr.s_addr == INADDR_ANY)
460
533
  {
461
- if(addr.saIn.sin_addr.s_addr == INADDR_ANY)
462
- {
463
- ipv4 = true;
464
- return true;
465
- }
466
- }
467
- else if(addr.saStorage.ss_family)
468
- {
469
- if(IN6_IS_ADDR_UNSPECIFIED(&addr.saIn6.sin6_addr))
470
- {
471
- ipv4 = false;
472
- return true;
473
- }
534
+ ipv4 = true;
535
+ return true;
474
536
  }
475
537
  }
476
- catch(const DNSException&)
538
+ else if(addr.saStorage.ss_family == AF_INET6)
477
539
  {
540
+ if(IN6_IS_ADDR_UNSPECIFIED(&addr.saIn6.sin6_addr))
541
+ {
542
+ ipv4 = false;
543
+ return true;
544
+ }
478
545
  }
479
546
  return false;
480
547
  }
481
548
 
482
549
  int
483
- getInterfaceIndex(const string& name)
550
+ getInterfaceIndex(const string& intf)
484
551
  {
485
- if(name.empty())
552
+ if(intf.empty())
486
553
  {
487
554
  return 0;
488
555
  }
489
556
 
490
- int index = 0;
557
+ string name;
558
+ bool isAddr;
559
+ in6_addr addr;
560
+ string::size_type pos = intf.find("%");
561
+ if(pos != string::npos)
562
+ {
563
+ //
564
+ // If it's a link-local address, use the zone indice.
565
+ //
566
+ isAddr = false;
567
+ name = intf.substr(pos + 1);
568
+ }
569
+ else
570
+ {
571
+ //
572
+ // Then check if it's an IPv6 address. If it's an address we'll
573
+ // look for the interface index by address.
574
+ //
575
+ isAddr = inet_pton(AF_INET6, intf.c_str(), &addr) > 0;
576
+ name = intf;
577
+ }
491
578
 
492
579
  //
493
- // First check if index
580
+ // Check if index
494
581
  //
582
+ int index = -1;
495
583
  istringstream p(name);
496
584
  if((p >> index) && p.eof())
497
585
  {
498
586
  return index;
499
587
  }
500
588
 
501
- //
502
- // Then check if it's an IPv6 address. If it's an address we'll
503
- // look for the interface index by address.
504
- //
505
- in6_addr addr;
506
- bool isAddr = inet_pton(AF_INET6, name.c_str(), &addr) > 0;
507
-
508
589
  #ifdef _WIN32
509
590
  IP_ADAPTER_ADDRESSES addrs;
510
591
  ULONG buflen = 0;
@@ -545,7 +626,7 @@ getInterfaceIndex(const string& name)
545
626
  // Don't need to pass a wide string converter as the wide string
546
627
  // come from Windows API.
547
628
  //
548
- if(IceUtil::wstringToString(paddrs->FriendlyName, IceUtil::getProcessStringConverter()) == name)
629
+ if(wstringToString(paddrs->FriendlyName, getProcessStringConverter()) == name)
549
630
  {
550
631
  index = paddrs->Ipv6IfIndex;
551
632
  break;
@@ -556,6 +637,10 @@ getInterfaceIndex(const string& name)
556
637
  }
557
638
  delete[] buf;
558
639
  }
640
+ if(index < 0) // interface not found
641
+ {
642
+ throw Ice::SocketException(__FILE__, __LINE__, WSAEINVAL);
643
+ }
559
644
  #elif !defined(__hpux)
560
645
 
561
646
  //
@@ -575,7 +660,7 @@ getInterfaceIndex(const string& name)
575
660
  struct sockaddr_in6* ipv6Addr = reinterpret_cast<struct sockaddr_in6*>(curr->ifa_addr);
576
661
  if(memcmp(&addr, &ipv6Addr->sin6_addr, sizeof(in6_addr)) == 0)
577
662
  {
578
- index = if_nametoindex(curr->ifa_name);
663
+ index = static_cast<int>(if_nametoindex(curr->ifa_name));
579
664
  break;
580
665
  }
581
666
  }
@@ -640,7 +725,7 @@ getInterfaceIndex(const string& name)
640
725
  struct sockaddr_in6* ipv6Addr = reinterpret_cast<struct sockaddr_in6*>(&ifr[i].ifr_addr);
641
726
  if(memcmp(&addr, &ipv6Addr->sin6_addr, sizeof(in6_addr)) == 0)
642
727
  {
643
- index = if_nametoindex(ifr[i].ifr_name);
728
+ index = static_cast<int>(if_nametoindex(ifr[i].ifr_name));
644
729
  break;
645
730
  }
646
731
  }
@@ -651,7 +736,12 @@ getInterfaceIndex(const string& name)
651
736
  }
652
737
  else // Look for an interface with the given name.
653
738
  {
654
- index = if_nametoindex(name.c_str());
739
+ index = static_cast<int>(if_nametoindex(name.c_str()));
740
+ }
741
+ if(index <= 0)
742
+ {
743
+ // index == 0 if if_nametoindex returned 0, < 0 if name wasn't found
744
+ throw Ice::SocketException(__FILE__, __LINE__, index == 0 ? getSocketErrno() : ENXIO);
655
745
  }
656
746
  #endif
657
747
 
@@ -689,19 +779,20 @@ getInterfaceAddress(const string& name)
689
779
  // Don't need to pass a wide string converter as the wide string come
690
780
  // from Windows API.
691
781
  //
692
- if(IceUtil::wstringToString(paddrs->FriendlyName, IceUtil::getProcessStringConverter()) == name)
782
+ if(wstringToString(paddrs->FriendlyName, getProcessStringConverter()) == name)
693
783
  {
694
784
  struct sockaddr_in addrin;
695
785
  memcpy(&addrin, paddrs->FirstUnicastAddress->Address.lpSockaddr,
696
786
  paddrs->FirstUnicastAddress->Address.iSockaddrLength);
697
- addr = addrin.sin_addr;
698
- break;
787
+ delete[] buf;
788
+ return addrin.sin_addr;
699
789
  }
700
790
  paddrs = paddrs->Next;
701
791
  }
702
792
  }
703
793
  delete[] buf;
704
794
  }
795
+ throw Ice::SocketException(__FILE__, __LINE__, WSAEINVAL);
705
796
  #else
706
797
  ifreq if_address;
707
798
  strcpy(if_address.ifr_name, name.c_str());
@@ -709,14 +800,12 @@ getInterfaceAddress(const string& name)
709
800
  SOCKET fd = createSocketImpl(false, AF_INET);
710
801
  int rc = ioctl(fd, SIOCGIFADDR, &if_address);
711
802
  closeSocketNoThrow(fd);
712
-
713
- if(rc != SOCKET_ERROR)
803
+ if(rc == SOCKET_ERROR)
714
804
  {
715
- addr = reinterpret_cast<struct sockaddr_in*>(&if_address.ifr_addr)->sin_addr;
805
+ throw Ice::SocketException(__FILE__, __LINE__, getSocketErrno());
716
806
  }
807
+ return reinterpret_cast<struct sockaddr_in*>(&if_address.ifr_addr)->sin_addr;
717
808
  #endif
718
-
719
- return addr;
720
809
  }
721
810
 
722
811
  int
@@ -734,11 +823,57 @@ getAddressStorageSize(const Address& addr)
734
823
  return size;
735
824
  }
736
825
 
737
- #endif // #ifndef ICE_OS_WINRT
826
+ vector<Address>
827
+ getLoopbackAddresses(ProtocolSupport protocol, int port = 0)
828
+ {
829
+ vector<Address> result;
738
830
 
831
+ Address addr;
832
+ memset(&addr.saStorage, 0, sizeof(sockaddr_storage));
833
+
834
+ //
835
+ // We don't use getaddrinfo when host is empty as it's not portable (some old Linux
836
+ // versions don't support it).
837
+ //
838
+ if(protocol != EnableIPv4)
839
+ {
840
+ addr.saIn6.sin6_family = AF_INET6;
841
+ addr.saIn6.sin6_port = htons(port);
842
+ addr.saIn6.sin6_addr = in6addr_loopback;
843
+ result.push_back(addr);
844
+ }
845
+ if(protocol != EnableIPv6)
846
+ {
847
+ addr.saIn.sin_family = AF_INET;
848
+ addr.saIn.sin_port = htons(port);
849
+ addr.saIn.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
850
+ result.push_back(addr);
851
+ }
852
+ return result;
853
+ }
854
+
855
+ #endif // #ifndef ICE_OS_UWP
856
+
857
+ }
858
+
859
+ ReadyCallback::~ReadyCallback()
860
+ {
861
+ // Out of line to avoid weak vtable
862
+ }
863
+
864
+ NativeInfo::~NativeInfo()
865
+ {
866
+ // Out of line to avoid weak vtable
867
+ }
868
+
869
+ void
870
+ NativeInfo::setReadyCallback(const ReadyCallbackPtr& callback)
871
+ {
872
+ _readyCallback = callback;
739
873
  }
740
874
 
741
875
  #ifdef ICE_USE_IOCP
876
+
742
877
  IceInternal::AsyncInfo::AsyncInfo(SocketOperation s)
743
878
  {
744
879
  ZeroMemory(this, sizeof(AsyncInfo));
@@ -757,12 +892,115 @@ IceInternal::NativeInfo::completed(SocketOperation operation)
757
892
  {
758
893
  if(!PostQueuedCompletionStatus(_handle, 0, _key, getAsyncInfo(operation)))
759
894
  {
760
- Ice::SocketException ex(__FILE__, __LINE__);
761
- ex.error = GetLastError();
762
- throw ex;
895
+ throw Ice::SocketException(__FILE__, __LINE__, GetLastError());
896
+ }
897
+ }
898
+
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;
763
995
  }
996
+ completed(op);
997
+ }
998
+
999
+ void
1000
+ IceInternal::NativeInfo::setCompletedHandler(SocketOperationCompletedHandler^ handler)
1001
+ {
1002
+ _completedHandler = handler;
764
1003
  }
765
- #elif defined(ICE_OS_WINRT)
766
1004
 
767
1005
  void
768
1006
  IceInternal::NativeInfo::completed(SocketOperation operation)
@@ -771,12 +1009,68 @@ IceInternal::NativeInfo::completed(SocketOperation operation)
771
1009
  _completedHandler(operation);
772
1010
  }
773
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
+ #else
1048
+
1049
+ void
1050
+ IceInternal::NativeInfo::setNewFd(SOCKET fd)
1051
+ {
1052
+ assert(_fd == INVALID_SOCKET); // This can only be called once, when the current socket isn't set yet.
1053
+ _newFd = fd;
1054
+ }
1055
+
1056
+ bool
1057
+ IceInternal::NativeInfo::newFd()
1058
+ {
1059
+ if(_newFd == INVALID_SOCKET)
1060
+ {
1061
+ return false;
1062
+ }
1063
+ assert(_fd == INVALID_SOCKET);
1064
+ swap(_fd, _newFd);
1065
+ return true;
1066
+ }
1067
+
774
1068
  #endif
775
1069
 
776
1070
  bool
777
1071
  IceInternal::noMoreFds(int error)
778
1072
  {
779
- #if defined(ICE_OS_WINRT)
1073
+ #if defined(ICE_OS_UWP)
780
1074
  return error == (int)SocketErrorStatus::TooManyOpenFiles;
781
1075
  #elif defined(_WIN32)
782
1076
  return error == WSAEMFILE;
@@ -785,7 +1079,7 @@ IceInternal::noMoreFds(int error)
785
1079
  #endif
786
1080
  }
787
1081
 
788
- #if defined(ICE_OS_WINRT)
1082
+ #if defined(ICE_OS_UWP)
789
1083
  string
790
1084
  IceInternal::errorToStringDNS(int)
791
1085
  {
@@ -803,7 +1097,7 @@ IceInternal::errorToStringDNS(int error)
803
1097
  }
804
1098
  #endif
805
1099
 
806
- #ifdef ICE_OS_WINRT
1100
+ #ifdef ICE_OS_UWP
807
1101
  vector<Address>
808
1102
  IceInternal::getAddresses(const string& host, int port, ProtocolSupport, Ice::EndpointSelectionType, bool, bool)
809
1103
  {
@@ -822,37 +1116,31 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport, Ice::En
822
1116
  // to Windows API.
823
1117
  //
824
1118
  addr.host = ref new HostName(ref new String(
825
- IceUtil::stringToWstring(host,
826
- IceUtil::getProcessStringConverter()).c_str()));
1119
+ stringToWstring(host,
1120
+ getProcessStringConverter()).c_str()));
827
1121
  }
828
1122
  stringstream os;
829
1123
  os << port;
830
1124
  //
831
1125
  // Don't need to use any string converter here as the port number use just
832
- // ACII characters.
1126
+ // ASCII characters.
833
1127
  //
834
- addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str());
1128
+ addr.port = ref new String(stringToWstring(os.str()).c_str());
835
1129
  result.push_back(addr);
836
1130
  return result;
837
1131
  }
838
1132
  catch(Platform::Exception^ pex)
839
1133
  {
840
- DNSException ex(__FILE__, __LINE__);
841
- ex.error = (int)SocketError::GetStatus(pex->HResult);
842
- ex.host = host;
843
- throw ex;
1134
+ throw DNSException(__FILE__, __LINE__, (int)SocketError::GetStatus(pex->HResult), host);
844
1135
  }
845
1136
 
846
1137
  }
847
1138
  #else
848
1139
  vector<Address>
849
1140
  IceInternal::getAddresses(const string& host, int port, ProtocolSupport protocol, Ice::EndpointSelectionType selType,
850
- bool preferIPv6, bool blocking)
1141
+ bool preferIPv6, bool canBlock)
851
1142
  {
852
1143
  vector<Address> result;
853
- Address addr;
854
-
855
- memset(&addr.saStorage, 0, sizeof(sockaddr_storage));
856
1144
 
857
1145
  //
858
1146
  // We don't use getaddrinfo when host is empty as it's not portable (some old Linux
@@ -860,28 +1148,18 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport protocol
860
1148
  //
861
1149
  if(host.empty())
862
1150
  {
863
- if(protocol != EnableIPv4)
864
- {
865
- addr.saIn6.sin6_family = AF_INET6;
866
- addr.saIn6.sin6_port = htons(port);
867
- addr.saIn6.sin6_addr = in6addr_loopback;
868
- result.push_back(addr);
869
- }
870
- if(protocol != EnableIPv6)
871
- {
872
- addr.saIn.sin_family = AF_INET;
873
- addr.saIn.sin_port = htons(port);
874
- addr.saIn.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
875
- result.push_back(addr);
876
- }
1151
+ result = getLoopbackAddresses(protocol, port);
877
1152
  sortAddresses(result, protocol, selType, preferIPv6);
878
1153
  return result;
879
1154
  }
880
1155
 
1156
+ Address addr;
1157
+ memset(&addr.saStorage, 0, sizeof(sockaddr_storage));
1158
+
881
1159
  struct addrinfo* info = 0;
882
1160
  int retry = 5;
883
1161
 
884
- struct addrinfo hints = { 0 };
1162
+ struct addrinfo hints = {};
885
1163
  if(protocol == EnableIPv4)
886
1164
  {
887
1165
  hints.ai_family = PF_INET;
@@ -895,7 +1173,7 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport protocol
895
1173
  hints.ai_family = PF_UNSPEC;
896
1174
  }
897
1175
 
898
- if(!blocking)
1176
+ if(!canBlock)
899
1177
  {
900
1178
  hints.ai_flags = AI_NUMERICHOST;
901
1179
  }
@@ -912,22 +1190,19 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport protocol
912
1190
  // address. However on some platforms (e.g. macOS 10.4.x)
913
1191
  // EAI_NODATA is also returned so we also check for it.
914
1192
  # ifdef EAI_NODATA
915
- if(!blocking && (rs == EAI_NONAME || rs == EAI_NODATA))
1193
+ if(!canBlock && (rs == EAI_NONAME || rs == EAI_NODATA))
916
1194
  # else
917
- if(!blocking && rs == EAI_NONAME)
1195
+ if(!canBlock && rs == EAI_NONAME)
918
1196
  # endif
919
1197
  {
920
- return result; // Empty result indicates that a blocking lookup is necessary.
1198
+ return result; // Empty result indicates that a canBlock lookup is necessary.
921
1199
  }
922
1200
  else if(rs != 0)
923
1201
  {
924
- DNSException ex(__FILE__, __LINE__);
925
- ex.error = rs;
926
- ex.host = host;
927
- throw ex;
1202
+ throw DNSException(__FILE__, __LINE__, rs, host);
928
1203
  }
929
1204
 
930
- for(struct addrinfo* p = info; p != NULL; p = p->ai_next)
1205
+ for(struct addrinfo* p = info; p != ICE_NULLPTR; p = p->ai_next)
931
1206
  {
932
1207
  memcpy(&addr.saStorage, p->ai_addr, p->ai_addrlen);
933
1208
  if(p->ai_family == PF_INET)
@@ -958,20 +1233,18 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport protocol
958
1233
 
959
1234
  if(result.empty())
960
1235
  {
961
- DNSException ex(__FILE__, __LINE__);
962
- ex.host = host;
963
- throw ex;
1236
+ throw DNSException(__FILE__, __LINE__, 0, host);
964
1237
  }
965
1238
  sortAddresses(result, protocol, selType, preferIPv6);
966
1239
  return result;
967
1240
  }
968
1241
  #endif
969
1242
 
970
- #ifdef ICE_OS_WINRT
1243
+ #ifdef ICE_OS_UWP
971
1244
  ProtocolSupport
972
1245
  IceInternal::getProtocolSupport(const Address&)
973
1246
  {
974
- // For WinRT, there's no distinction between IPv4 and IPv6 adresses.
1247
+ // For UWP, there's no distinction between IPv4 and IPv6 adresses.
975
1248
  return EnableBoth;
976
1249
  }
977
1250
  #else
@@ -983,7 +1256,7 @@ IceInternal::getProtocolSupport(const Address& addr)
983
1256
  #endif
984
1257
 
985
1258
  Address
986
- IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport protocol, bool preferIPv6)
1259
+ IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport protocol, bool preferIPv6, bool canBlock)
987
1260
  {
988
1261
  //
989
1262
  // We don't use getaddrinfo when host is empty as it's not portable (some old Linux
@@ -992,14 +1265,14 @@ IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport p
992
1265
  if(host.empty())
993
1266
  {
994
1267
  Address addr;
995
- #ifdef ICE_OS_WINRT
1268
+ #ifdef ICE_OS_UWP
996
1269
  ostringstream os;
997
1270
  os << port;
998
1271
  //
999
1272
  // Don't need to use any string converter here as the port number use just
1000
1273
  // ASCII characters.
1001
1274
  //
1002
- addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str());
1275
+ addr.port = ref new String(stringToWstring(os.str()).c_str());
1003
1276
  addr.host = nullptr; // Equivalent of inaddr_any, see doBind implementation.
1004
1277
  #else
1005
1278
  memset(&addr.saStorage, 0, sizeof(sockaddr_storage));
@@ -1018,13 +1291,15 @@ IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport p
1018
1291
  #endif
1019
1292
  return addr;
1020
1293
  }
1021
- return getAddresses(host, port, protocol, Ice::Ordered, preferIPv6, true)[0];
1294
+ vector<Address> addrs = getAddresses(host, port, protocol, Ice::ICE_ENUM(EndpointSelectionType, Ordered),
1295
+ preferIPv6, canBlock);
1296
+ return addrs.empty() ? Address() : addrs[0];
1022
1297
  }
1023
1298
 
1024
1299
  int
1025
1300
  IceInternal::compareAddress(const Address& addr1, const Address& addr2)
1026
1301
  {
1027
- #ifdef ICE_OS_WINRT
1302
+ #ifdef ICE_OS_UWP
1028
1303
  int o = String::CompareOrdinal(addr1.port, addr2.port);
1029
1304
  if(o != 0)
1030
1305
  {
@@ -1099,7 +1374,7 @@ IceInternal::compareAddress(const Address& addr1, const Address& addr2)
1099
1374
  #endif
1100
1375
  }
1101
1376
 
1102
- #ifdef ICE_OS_WINRT
1377
+ #ifdef ICE_OS_UWP
1103
1378
  bool
1104
1379
  IceInternal::isIPv6Supported()
1105
1380
  {
@@ -1122,7 +1397,7 @@ IceInternal::isIPv6Supported()
1122
1397
  }
1123
1398
  #endif
1124
1399
 
1125
- #ifdef ICE_OS_WINRT
1400
+ #ifdef ICE_OS_UWP
1126
1401
  SOCKET
1127
1402
  IceInternal::createSocket(bool udp, const Address&)
1128
1403
  {
@@ -1136,7 +1411,7 @@ IceInternal::createSocket(bool udp, const Address& addr)
1136
1411
  }
1137
1412
  #endif
1138
1413
 
1139
- #ifndef ICE_OS_WINRT
1414
+ #ifndef ICE_OS_UWP
1140
1415
  SOCKET
1141
1416
  IceInternal::createServerSocket(bool udp, const Address& addr, ProtocolSupport protocol)
1142
1417
  {
@@ -1153,9 +1428,7 @@ IceInternal::createServerSocket(bool udp, const Address& addr, ProtocolSupport p
1153
1428
  }
1154
1429
  #endif
1155
1430
  closeSocketNoThrow(fd);
1156
- SocketException ex(__FILE__, __LINE__);
1157
- ex.error = getSocketErrno();
1158
- throw ex;
1431
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1159
1432
  }
1160
1433
  }
1161
1434
  return fd;
@@ -1171,7 +1444,7 @@ IceInternal::createServerSocket(bool udp, const Address& addr, ProtocolSupport)
1171
1444
  void
1172
1445
  IceInternal::closeSocketNoThrow(SOCKET fd)
1173
1446
  {
1174
- #if defined(ICE_OS_WINRT)
1447
+ #if defined(ICE_OS_UWP)
1175
1448
  //
1176
1449
  // NOTE: StreamSocket::Close or DatagramSocket::Close aren't
1177
1450
  // exposed in C++, you have to delete the socket to close
@@ -1194,7 +1467,7 @@ IceInternal::closeSocketNoThrow(SOCKET fd)
1194
1467
  void
1195
1468
  IceInternal::closeSocket(SOCKET fd)
1196
1469
  {
1197
- #if defined(ICE_OS_WINRT)
1470
+ #if defined(ICE_OS_UWP)
1198
1471
  //
1199
1472
  // NOTE: StreamSocket::Close or DatagramSocket::Close aren't
1200
1473
  // exposed in C++, you have to delete the socket to close
@@ -1207,9 +1480,7 @@ IceInternal::closeSocket(SOCKET fd)
1207
1480
  int error = WSAGetLastError();
1208
1481
  if(closesocket(fd) == SOCKET_ERROR)
1209
1482
  {
1210
- SocketException ex(__FILE__, __LINE__);
1211
- ex.error = getSocketErrno();
1212
- throw ex;
1483
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1213
1484
  }
1214
1485
  WSASetLastError(error);
1215
1486
  #else
@@ -1226,9 +1497,7 @@ IceInternal::closeSocket(SOCKET fd)
1226
1497
  if(close(fd) == SOCKET_ERROR)
1227
1498
  # endif
1228
1499
  {
1229
- SocketException ex(__FILE__, __LINE__);
1230
- ex.error = getSocketErrno();
1231
- throw ex;
1500
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1232
1501
  }
1233
1502
  errno = error;
1234
1503
  #endif
@@ -1245,13 +1514,11 @@ IceInternal::addrToString(const Address& addr)
1245
1514
  void
1246
1515
  IceInternal::fdToLocalAddress(SOCKET fd, Address& addr)
1247
1516
  {
1248
- #ifndef ICE_OS_WINRT
1517
+ #ifndef ICE_OS_UWP
1249
1518
  socklen_t len = static_cast<socklen_t>(sizeof(sockaddr_storage));
1250
1519
  if(getsockname(fd, &addr.sa, &len) == SOCKET_ERROR)
1251
1520
  {
1252
- SocketException ex(__FILE__, __LINE__);
1253
- ex.error = getSocketErrno();
1254
- throw ex;
1521
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1255
1522
  }
1256
1523
  #else
1257
1524
  StreamSocket^ stream = dynamic_cast<StreamSocket^>(fd);
@@ -1272,7 +1539,7 @@ IceInternal::fdToLocalAddress(SOCKET fd, Address& addr)
1272
1539
  bool
1273
1540
  IceInternal::fdToRemoteAddress(SOCKET fd, Address& addr)
1274
1541
  {
1275
- #ifndef ICE_OS_WINRT
1542
+ #ifndef ICE_OS_UWP
1276
1543
  socklen_t len = static_cast<socklen_t>(sizeof(sockaddr_storage));
1277
1544
  if(getpeername(fd, &addr.sa, &len) == SOCKET_ERROR)
1278
1545
  {
@@ -1282,9 +1549,7 @@ IceInternal::fdToRemoteAddress(SOCKET fd, Address& addr)
1282
1549
  }
1283
1550
  else
1284
1551
  {
1285
- SocketException ex(__FILE__, __LINE__);
1286
- ex.error = getSocketErrno();
1287
- throw ex;
1552
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1288
1553
  }
1289
1554
  }
1290
1555
 
@@ -1427,14 +1692,14 @@ IceInternal::addressesToString(const Address& localAddr, const Address& remoteAd
1427
1692
  bool
1428
1693
  IceInternal::isAddressValid(const Address& addr)
1429
1694
  {
1430
- #ifndef ICE_OS_WINRT
1695
+ #ifndef ICE_OS_UWP
1431
1696
  return addr.saStorage.ss_family != AF_UNSPEC;
1432
1697
  #else
1433
1698
  return addr.host != nullptr || addr.port != nullptr;
1434
1699
  #endif
1435
1700
  }
1436
1701
 
1437
- #ifdef ICE_OS_WINRT
1702
+ #ifdef ICE_OS_UWP
1438
1703
  vector<string>
1439
1704
  IceInternal::getHostsForEndpointExpand(const string& host, ProtocolSupport protocolSupport, bool includeLoopback)
1440
1705
  {
@@ -1446,11 +1711,10 @@ IceInternal::getHostsForEndpointExpand(const string& host, ProtocolSupport proto
1446
1711
  HostName^ h = it->Current;
1447
1712
  if(h->IPInformation != nullptr && h->IPInformation->NetworkAdapter != nullptr)
1448
1713
  {
1449
- hosts.push_back(IceUtil::wstringToString(h->CanonicalName->Data(),
1450
- IceUtil::getProcessStringConverter()));
1714
+ hosts.push_back(wstringToString(h->CanonicalName->Data(), getProcessStringConverter()));
1451
1715
  }
1452
1716
  }
1453
- if(includeLoopback)
1717
+ if(hosts.empty() || includeLoopback)
1454
1718
  {
1455
1719
  if(protocolSupport != EnableIPv6)
1456
1720
  {
@@ -1464,6 +1728,32 @@ IceInternal::getHostsForEndpointExpand(const string& host, ProtocolSupport proto
1464
1728
  }
1465
1729
  return hosts;
1466
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
+ }
1467
1757
  #else
1468
1758
  vector<string>
1469
1759
  IceInternal::getHostsForEndpointExpand(const string& host, ProtocolSupport protocolSupport, bool includeLoopback)
@@ -1472,7 +1762,7 @@ IceInternal::getHostsForEndpointExpand(const string& host, ProtocolSupport proto
1472
1762
  bool ipv4Wildcard = false;
1473
1763
  if(isWildcard(host, protocolSupport, ipv4Wildcard))
1474
1764
  {
1475
- vector<Address> addrs = getLocalAddresses(ipv4Wildcard ? EnableIPv4 : protocolSupport, includeLoopback);
1765
+ vector<Address> addrs = getLocalAddresses(ipv4Wildcard ? EnableIPv4 : protocolSupport, includeLoopback, false);
1476
1766
  for(vector<Address>::const_iterator p = addrs.begin(); p != addrs.end(); ++p)
1477
1767
  {
1478
1768
  //
@@ -1485,15 +1775,44 @@ IceInternal::getHostsForEndpointExpand(const string& host, ProtocolSupport proto
1485
1775
  hosts.push_back(inetAddrToString(*p));
1486
1776
  }
1487
1777
  }
1778
+ if(hosts.empty())
1779
+ {
1780
+ // Return loopback if no other local addresses are available.
1781
+ addrs = getLoopbackAddresses(protocolSupport);
1782
+ for(vector<Address>::const_iterator p = addrs.begin(); p != addrs.end(); ++p)
1783
+ {
1784
+ hosts.push_back(inetAddrToString(*p));
1785
+ }
1786
+ }
1488
1787
  }
1489
1788
  return hosts; // An empty host list indicates to just use the given host.
1490
1789
  }
1790
+
1791
+ vector<string>
1792
+ IceInternal::getInterfacesForMulticast(const string& intf, ProtocolSupport protocolSupport)
1793
+ {
1794
+ vector<string> interfaces;
1795
+ bool ipv4Wildcard = false;
1796
+ if(isWildcard(intf, protocolSupport, ipv4Wildcard))
1797
+ {
1798
+ vector<Address> addrs = getLocalAddresses(ipv4Wildcard ? EnableIPv4 : protocolSupport, true, true);
1799
+ for(vector<Address>::const_iterator p = addrs.begin(); p != addrs.end(); ++p)
1800
+ {
1801
+ interfaces.push_back(inetAddrToString(*p)); // We keep link local addresses for multicast
1802
+ }
1803
+ }
1804
+ if(interfaces.empty())
1805
+ {
1806
+ interfaces.push_back(intf);
1807
+ }
1808
+ return interfaces;
1809
+ }
1491
1810
  #endif
1492
1811
 
1493
1812
  string
1494
1813
  IceInternal::inetAddrToString(const Address& ss)
1495
1814
  {
1496
- #ifndef ICE_OS_WINRT
1815
+ #ifndef ICE_OS_UWP
1497
1816
  int size = getAddressStorageSize(ss);
1498
1817
  if(size == 0)
1499
1818
  {
@@ -1502,7 +1821,8 @@ IceInternal::inetAddrToString(const Address& ss)
1502
1821
 
1503
1822
  char namebuf[1024];
1504
1823
  namebuf[0] = '\0';
1505
- getnameinfo(&ss.sa, size, namebuf, static_cast<socklen_t>(sizeof(namebuf)), 0, 0, NI_NUMERICHOST);
1824
+ getnameinfo(&ss.sa, static_cast<socklen_t>(size), namebuf, static_cast<socklen_t>(sizeof(namebuf)), 0, 0,
1825
+ NI_NUMERICHOST);
1506
1826
  return string(namebuf);
1507
1827
  #else
1508
1828
  if(ss.host == nullptr)
@@ -1515,7 +1835,7 @@ IceInternal::inetAddrToString(const Address& ss)
1515
1835
  // Don't need to pass a wide string converter as the wide string come
1516
1836
  // from Windows API.
1517
1837
  //
1518
- return IceUtil::wstringToString(ss.host->RawName->Data(), IceUtil::getProcessStringConverter());
1838
+ return wstringToString(ss.host->RawName->Data(), getProcessStringConverter());
1519
1839
  }
1520
1840
  #endif
1521
1841
  }
@@ -1523,7 +1843,7 @@ IceInternal::inetAddrToString(const Address& ss)
1523
1843
  int
1524
1844
  IceInternal::getPort(const Address& addr)
1525
1845
  {
1526
- #ifndef ICE_OS_WINRT
1846
+ #ifndef ICE_OS_UWP
1527
1847
  if(addr.saStorage.ss_family == AF_INET)
1528
1848
  {
1529
1849
  return ntohs(addr.saIn.sin_port);
@@ -1537,11 +1857,11 @@ IceInternal::getPort(const Address& addr)
1537
1857
  return -1;
1538
1858
  }
1539
1859
  #else
1540
- IceUtil::Int64 port;
1860
+ IceUtil::Int64 port = 0;
1541
1861
  //
1542
1862
  // Don't need to use any string converter here as the port number use just ASCII characters.
1543
1863
  //
1544
- if(addr.port == nullptr || !IceUtilInternal::stringToInt64(IceUtil::wstringToString(addr.port->Data()), port))
1864
+ if(addr.port == nullptr || !IceUtilInternal::stringToInt64(wstringToString(addr.port->Data()), port))
1545
1865
  {
1546
1866
  return -1;
1547
1867
  }
@@ -1552,7 +1872,7 @@ IceInternal::getPort(const Address& addr)
1552
1872
  void
1553
1873
  IceInternal::setPort(Address& addr, int port)
1554
1874
  {
1555
- #ifndef ICE_OS_WINRT
1875
+ #ifndef ICE_OS_UWP
1556
1876
  if(addr.saStorage.ss_family == AF_INET)
1557
1877
  {
1558
1878
  addr.saIn.sin_port = htons(port);
@@ -1567,16 +1887,16 @@ IceInternal::setPort(Address& addr, int port)
1567
1887
  os << port;
1568
1888
  //
1569
1889
  // Don't need to use any string converter here as the port number use just
1570
- // ACII characters.
1890
+ // ASCII characters.
1571
1891
  //
1572
- addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str());
1892
+ addr.port = ref new String(stringToWstring(os.str()).c_str());
1573
1893
  #endif
1574
1894
  }
1575
1895
 
1576
1896
  bool
1577
1897
  IceInternal::isMulticast(const Address& addr)
1578
1898
  {
1579
- #ifndef ICE_OS_WINRT
1899
+ #ifndef ICE_OS_UWP
1580
1900
  if(addr.saStorage.ss_family == AF_INET)
1581
1901
  {
1582
1902
  return IN_MULTICAST(ntohl(addr.saIn.sin_addr.s_addr));
@@ -1594,7 +1914,7 @@ IceInternal::isMulticast(const Address& addr)
1594
1914
  // Don't need to use string converters here, this is just to do a local
1595
1915
  // comparison to find if the address is multicast.
1596
1916
  //
1597
- string host = IceUtil::wstringToString(addr.host->RawName->Data());
1917
+ string host = wstringToString(addr.host->RawName->Data());
1598
1918
  string ip = IceUtilInternal::toUpper(host);
1599
1919
  vector<string> tokens;
1600
1920
  IceUtilInternal::splitString(ip, ".", tokens);
@@ -1689,7 +2009,7 @@ IceInternal::setTcpBufSize(SOCKET fd, int rcvSize, int sndSize, const ProtocolIn
1689
2009
  }
1690
2010
  }
1691
2011
 
1692
- #ifdef ICE_OS_WINRT
2012
+ #ifdef ICE_OS_UWP
1693
2013
  void
1694
2014
  IceInternal::setBlock(SOCKET fd, bool)
1695
2015
  {
@@ -1705,9 +2025,7 @@ IceInternal::setBlock(SOCKET fd, bool block)
1705
2025
  if(ioctlsocket(fd, FIONBIO, &arg) == SOCKET_ERROR)
1706
2026
  {
1707
2027
  closeSocketNoThrow(fd);
1708
- SocketException ex(__FILE__, __LINE__);
1709
- ex.error = WSAGetLastError();
1710
- throw ex;
2028
+ throw SocketException(__FILE__, __LINE__, WSAGetLastError());
1711
2029
  }
1712
2030
  }
1713
2031
  else
@@ -1716,9 +2034,7 @@ IceInternal::setBlock(SOCKET fd, bool block)
1716
2034
  if(ioctlsocket(fd, FIONBIO, &arg) == SOCKET_ERROR)
1717
2035
  {
1718
2036
  closeSocketNoThrow(fd);
1719
- SocketException ex(__FILE__, __LINE__);
1720
- ex.error = WSAGetLastError();
1721
- throw ex;
2037
+ throw SocketException(__FILE__, __LINE__, WSAGetLastError());
1722
2038
  }
1723
2039
  }
1724
2040
  #else
@@ -1729,9 +2045,7 @@ IceInternal::setBlock(SOCKET fd, bool block)
1729
2045
  if(fcntl(fd, F_SETFL, flags) == SOCKET_ERROR)
1730
2046
  {
1731
2047
  closeSocketNoThrow(fd);
1732
- SocketException ex(__FILE__, __LINE__);
1733
- ex.error = errno;
1734
- throw ex;
2048
+ throw SocketException(__FILE__, __LINE__, errno);
1735
2049
  }
1736
2050
  }
1737
2051
  else
@@ -1741,9 +2055,7 @@ IceInternal::setBlock(SOCKET fd, bool block)
1741
2055
  if(fcntl(fd, F_SETFL, flags) == SOCKET_ERROR)
1742
2056
  {
1743
2057
  closeSocketNoThrow(fd);
1744
- SocketException ex(__FILE__, __LINE__);
1745
- ex.error = errno;
1746
- throw ex;
2058
+ throw SocketException(__FILE__, __LINE__, errno);
1747
2059
  }
1748
2060
  }
1749
2061
  #endif
@@ -1753,13 +2065,11 @@ IceInternal::setBlock(SOCKET fd, bool block)
1753
2065
  void
1754
2066
  IceInternal::setSendBufferSize(SOCKET fd, int sz)
1755
2067
  {
1756
- #ifndef ICE_OS_WINRT
2068
+ #ifndef ICE_OS_UWP
1757
2069
  if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, reinterpret_cast<char*>(&sz), int(sizeof(int))) == SOCKET_ERROR)
1758
2070
  {
1759
2071
  closeSocketNoThrow(fd);
1760
- SocketException ex(__FILE__, __LINE__);
1761
- ex.error = getSocketErrno();
1762
- throw ex;
2072
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1763
2073
  }
1764
2074
  #else
1765
2075
  StreamSocket^ stream = dynamic_cast<StreamSocket^>(fd);
@@ -1773,16 +2083,14 @@ IceInternal::setSendBufferSize(SOCKET fd, int sz)
1773
2083
  int
1774
2084
  IceInternal::getSendBufferSize(SOCKET fd)
1775
2085
  {
1776
- #ifndef ICE_OS_WINRT
2086
+ #ifndef ICE_OS_UWP
1777
2087
  int sz;
1778
2088
  socklen_t len = sizeof(sz);
1779
2089
  if(getsockopt(fd, SOL_SOCKET, SO_SNDBUF, reinterpret_cast<char*>(&sz), &len) == SOCKET_ERROR ||
1780
2090
  static_cast<unsigned int>(len) != sizeof(sz))
1781
2091
  {
1782
2092
  closeSocketNoThrow(fd);
1783
- SocketException ex(__FILE__, __LINE__);
1784
- ex.error = getSocketErrno();
1785
- throw ex;
2093
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1786
2094
  }
1787
2095
  return sz;
1788
2096
  #else
@@ -1795,7 +2103,7 @@ IceInternal::getSendBufferSize(SOCKET fd)
1795
2103
  #endif
1796
2104
  }
1797
2105
 
1798
- #ifdef ICE_OS_WINRT
2106
+ #ifdef ICE_OS_UWP
1799
2107
  void
1800
2108
  IceInternal::setRecvBufferSize(SOCKET, int)
1801
2109
  {
@@ -1807,9 +2115,7 @@ IceInternal::setRecvBufferSize(SOCKET fd, int sz)
1807
2115
  if(setsockopt(fd, SOL_SOCKET, SO_RCVBUF, reinterpret_cast<char*>(&sz), int(sizeof(int))) == SOCKET_ERROR)
1808
2116
  {
1809
2117
  closeSocketNoThrow(fd);
1810
- SocketException ex(__FILE__, __LINE__);
1811
- ex.error = getSocketErrno();
1812
- throw ex;
2118
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1813
2119
  }
1814
2120
  }
1815
2121
  #endif
@@ -1817,16 +2123,14 @@ IceInternal::setRecvBufferSize(SOCKET fd, int sz)
1817
2123
  int
1818
2124
  IceInternal::getRecvBufferSize(SOCKET fd)
1819
2125
  {
1820
- #ifndef ICE_OS_WINRT
2126
+ #ifndef ICE_OS_UWP
1821
2127
  int sz;
1822
2128
  socklen_t len = sizeof(sz);
1823
2129
  if(getsockopt(fd, SOL_SOCKET, SO_RCVBUF, reinterpret_cast<char*>(&sz), &len) == SOCKET_ERROR ||
1824
2130
  static_cast<unsigned int>(len) != sizeof(sz))
1825
2131
  {
1826
2132
  closeSocketNoThrow(fd);
1827
- SocketException ex(__FILE__, __LINE__);
1828
- ex.error = getSocketErrno();
1829
- throw ex;
2133
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1830
2134
  }
1831
2135
  return sz;
1832
2136
  #else
@@ -1834,31 +2138,39 @@ IceInternal::getRecvBufferSize(SOCKET fd)
1834
2138
  #endif
1835
2139
  }
1836
2140
 
1837
- #ifndef ICE_OS_WINRT
2141
+ #ifndef ICE_OS_UWP
1838
2142
  void
1839
2143
  IceInternal::setMcastGroup(SOCKET fd, const Address& group, const string& intf)
1840
2144
  {
1841
- int rc;
1842
- if(group.saStorage.ss_family == AF_INET)
1843
- {
1844
- struct ip_mreq mreq;
1845
- mreq.imr_multiaddr = group.saIn.sin_addr;
1846
- mreq.imr_interface = getInterfaceAddress(intf);
1847
- rc = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, reinterpret_cast<char*>(&mreq), int(sizeof(mreq)));
1848
- }
1849
- else
2145
+ vector<string> interfaces = getInterfacesForMulticast(intf, getProtocolSupport(group));
2146
+ set<int> indexes;
2147
+ for(vector<string>::const_iterator p = interfaces.begin(); p != interfaces.end(); ++p)
1850
2148
  {
1851
- struct ipv6_mreq mreq;
1852
- mreq.ipv6mr_multiaddr = group.saIn6.sin6_addr;
1853
- mreq.ipv6mr_interface = getInterfaceIndex(intf);
1854
- rc = setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, reinterpret_cast<char*>(&mreq), int(sizeof(mreq)));
1855
- }
1856
- if(rc == SOCKET_ERROR)
1857
- {
1858
- closeSocketNoThrow(fd);
1859
- SocketException ex(__FILE__, __LINE__);
1860
- ex.error = getSocketErrno();
1861
- throw ex;
2149
+ int rc = 0;
2150
+ if(group.saStorage.ss_family == AF_INET)
2151
+ {
2152
+ struct ip_mreq mreq;
2153
+ mreq.imr_multiaddr = group.saIn.sin_addr;
2154
+ mreq.imr_interface = getInterfaceAddress(*p);
2155
+ rc = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, reinterpret_cast<char*>(&mreq), int(sizeof(mreq)));
2156
+ }
2157
+ else
2158
+ {
2159
+ int index = getInterfaceIndex(*p);
2160
+ if(indexes.find(index) == indexes.end()) // Don't join twice the same interface (if it has multiple IPs)
2161
+ {
2162
+ indexes.insert(index);
2163
+ struct ipv6_mreq mreq;
2164
+ mreq.ipv6mr_multiaddr = group.saIn6.sin6_addr;
2165
+ mreq.ipv6mr_interface = static_cast<unsigned int>(index);
2166
+ rc = setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, reinterpret_cast<char*>(&mreq), int(sizeof(mreq)));
2167
+ }
2168
+ }
2169
+ if(rc == SOCKET_ERROR)
2170
+ {
2171
+ closeSocketNoThrow(fd);
2172
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2173
+ }
1862
2174
  }
1863
2175
  }
1864
2176
  #else
@@ -1868,9 +2180,34 @@ IceInternal::setMcastGroup(SOCKET fd, const Address& group, const string&)
1868
2180
  try
1869
2181
  {
1870
2182
  //
1871
- // NOTE: WinRT doesn't allow specyfing the interface.
2183
+ // NOTE: UWP mcast interface is set earlier in doBind.
1872
2184
  //
1873
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
+
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());
1874
2211
  }
1875
2212
  catch(Platform::Exception^ pex)
1876
2213
  {
@@ -1879,7 +2216,7 @@ IceInternal::setMcastGroup(SOCKET fd, const Address& group, const string&)
1879
2216
  }
1880
2217
  #endif
1881
2218
 
1882
- #ifdef ICE_OS_WINRT
2219
+ #ifdef ICE_OS_UWP
1883
2220
  void
1884
2221
  IceInternal::setMcastInterface(SOCKET, const string&, const Address&)
1885
2222
  {
@@ -1902,14 +2239,12 @@ IceInternal::setMcastInterface(SOCKET fd, const string& intf, const Address& add
1902
2239
  if(rc == SOCKET_ERROR)
1903
2240
  {
1904
2241
  closeSocketNoThrow(fd);
1905
- SocketException ex(__FILE__, __LINE__);
1906
- ex.error = getSocketErrno();
1907
- throw ex;
2242
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1908
2243
  }
1909
2244
  }
1910
2245
  #endif
1911
2246
 
1912
- #ifdef ICE_OS_WINRT
2247
+ #ifdef ICE_OS_UWP
1913
2248
  void
1914
2249
  IceInternal::setMcastTtl(SOCKET, int, const Address&)
1915
2250
  {
@@ -1930,14 +2265,12 @@ IceInternal::setMcastTtl(SOCKET fd, int ttl, const Address& addr)
1930
2265
  if(rc == SOCKET_ERROR)
1931
2266
  {
1932
2267
  closeSocketNoThrow(fd);
1933
- SocketException ex(__FILE__, __LINE__);
1934
- ex.error = getSocketErrno();
1935
- throw ex;
2268
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1936
2269
  }
1937
2270
  }
1938
2271
  #endif
1939
2272
 
1940
- #ifdef ICE_OS_WINRT
2273
+ #ifdef ICE_OS_UWP
1941
2274
  void
1942
2275
  IceInternal::setReuseAddress(SOCKET, bool)
1943
2276
  {
@@ -1950,48 +2283,56 @@ IceInternal::setReuseAddress(SOCKET fd, bool reuse)
1950
2283
  if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char*>(&flag), int(sizeof(int))) == SOCKET_ERROR)
1951
2284
  {
1952
2285
  closeSocketNoThrow(fd);
1953
- SocketException ex(__FILE__, __LINE__);
1954
- ex.error = getSocketErrno();
1955
- throw ex;
2286
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1956
2287
  }
1957
2288
  }
1958
2289
  #endif
1959
2290
 
2291
+ #ifdef ICE_OS_UWP
2292
+ namespace
2293
+ {
1960
2294
 
1961
- #ifdef ICE_OS_WINRT
1962
2295
  void
1963
2296
  checkResultAndWait(IAsyncAction^ action)
1964
2297
  {
1965
- if(action->Status == Windows::Foundation::AsyncStatus::Started)
2298
+ auto status = action->Status;
2299
+ switch(status)
1966
2300
  {
1967
- IceUtilInternal::CountDownLatch count(1);
1968
- HRESULT result = 0;
1969
- action->Completed = ref new AsyncActionCompletedHandler(
1970
- [&count, &result] (IAsyncAction^ action, Windows::Foundation::AsyncStatus status)
1971
- {
1972
- if(status != Windows::Foundation::AsyncStatus::Completed)
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)
1973
2306
  {
1974
- result = action->ErrorCode.Value;
1975
- }
1976
- count.countDown();
1977
- });
1978
- count.await();
1979
- if(result)
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:
1980
2318
  {
1981
- checkErrorCode(__FILE__, __LINE__, result);
2319
+ checkErrorCode(__FILE__, __LINE__, action->ErrorCode.Value);
2320
+ break;
2321
+ }
2322
+ default:
2323
+ {
2324
+ break;
1982
2325
  }
1983
2326
  }
1984
- else if(action->Status == Windows::Foundation::AsyncStatus::Error)
1985
- {
1986
- checkErrorCode(__FILE__, __LINE__, action->ErrorCode.Value);
1987
- }
2327
+ }
2328
+
1988
2329
  }
1989
2330
  #endif
1990
2331
 
2332
+ #ifdef ICE_OS_UWP
1991
2333
  Address
1992
- IceInternal::doBind(SOCKET fd, const Address& addr)
2334
+ IceInternal::doBind(SOCKET fd, const Address& addr, const string& intf)
1993
2335
  {
1994
- #ifdef ICE_OS_WINRT
1995
2336
  Address local;
1996
2337
  try
1997
2338
  {
@@ -2015,7 +2356,32 @@ IceInternal::doBind(SOCKET fd, const Address& addr)
2015
2356
  {
2016
2357
  if(addr.host == nullptr) // inaddr_any
2017
2358
  {
2018
- checkResultAndWait(datagram->BindServiceNameAsync(addr.port));
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
+ }
2019
2385
  }
2020
2386
  else
2021
2387
  {
@@ -2031,16 +2397,18 @@ IceInternal::doBind(SOCKET fd, const Address& addr)
2031
2397
  throw;
2032
2398
  }
2033
2399
  return local;
2400
+ }
2034
2401
  #else
2402
+ Address
2403
+ IceInternal::doBind(SOCKET fd, const Address& addr, const string&)
2404
+ {
2035
2405
  int size = getAddressStorageSize(addr);
2036
2406
  assert(size != 0);
2037
2407
 
2038
- if(::bind(fd, &addr.sa, size) == SOCKET_ERROR)
2408
+ if(::bind(fd, &addr.sa, static_cast<socklen_t>(size)) == SOCKET_ERROR)
2039
2409
  {
2040
2410
  closeSocketNoThrow(fd);
2041
- SocketException ex(__FILE__, __LINE__);
2042
- ex.error = getSocketErrno();
2043
- throw ex;
2411
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2044
2412
  }
2045
2413
 
2046
2414
  Address local;
@@ -2052,15 +2420,16 @@ IceInternal::doBind(SOCKET fd, const Address& addr)
2052
2420
  assert(ret != SOCKET_ERROR);
2053
2421
  # endif
2054
2422
  return local;
2055
- #endif
2056
2423
  }
2424
+ #endif
2057
2425
 
2058
- #ifndef ICE_OS_WINRT
2426
+ #ifndef ICE_OS_UWP
2059
2427
 
2060
2428
  Address
2061
2429
  IceInternal::getNumericAddress(const std::string& address)
2062
2430
  {
2063
- vector<Address> addrs = getAddresses(address, 0, EnableBoth, Ice::Ordered, false, false);
2431
+ vector<Address> addrs = getAddresses(address, 0, EnableBoth, Ice::ICE_ENUM(EndpointSelectionType, Ordered), false,
2432
+ false);
2064
2433
  if(addrs.empty())
2065
2434
  {
2066
2435
  return Address();
@@ -2242,9 +2611,7 @@ repeatListen:
2242
2611
  }
2243
2612
 
2244
2613
  closeSocketNoThrow(fd);
2245
- SocketException ex(__FILE__, __LINE__);
2246
- ex.error = getSocketErrno();
2247
- throw ex;
2614
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2248
2615
  }
2249
2616
  }
2250
2617
 
@@ -2260,7 +2627,7 @@ repeatConnect:
2260
2627
  int size = getAddressStorageSize(addr);
2261
2628
  assert(size != 0);
2262
2629
 
2263
- if(::connect(fd, &addr.sa, size) == SOCKET_ERROR)
2630
+ if(::connect(fd, &addr.sa, static_cast<socklen_t>(size)) == SOCKET_ERROR)
2264
2631
  {
2265
2632
  if(interrupted())
2266
2633
  {
@@ -2275,21 +2642,15 @@ repeatConnect:
2275
2642
  closeSocketNoThrow(fd);
2276
2643
  if(connectionRefused())
2277
2644
  {
2278
- ConnectionRefusedException ex(__FILE__, __LINE__);
2279
- ex.error = getSocketErrno();
2280
- throw ex;
2645
+ throw ConnectionRefusedException(__FILE__, __LINE__, getSocketErrno());
2281
2646
  }
2282
2647
  else if(connectFailed())
2283
2648
  {
2284
- ConnectFailedException ex(__FILE__, __LINE__);
2285
- ex.error = getSocketErrno();
2286
- throw ex;
2649
+ throw ConnectFailedException(__FILE__, __LINE__, getSocketErrno());
2287
2650
  }
2288
2651
  else
2289
2652
  {
2290
- SocketException ex(__FILE__, __LINE__);
2291
- ex.error = getSocketErrno();
2292
- throw ex;
2653
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2293
2654
  }
2294
2655
  }
2295
2656
 
@@ -2305,9 +2666,7 @@ repeatConnect:
2305
2666
  fdToLocalAddress(fd, localAddr);
2306
2667
  if(compareAddress(addr, localAddr) == 0)
2307
2668
  {
2308
- ConnectionRefusedException ex(__FILE__, __LINE__);
2309
- ex.error = 0; // No appropriate errno
2310
- throw ex;
2669
+ throw ConnectionRefusedException(__FILE__, __LINE__, 0); // No appropriate errno
2311
2670
  }
2312
2671
  }
2313
2672
  catch(const LocalException&)
@@ -2340,9 +2699,7 @@ IceInternal::doFinishConnect(SOCKET fd)
2340
2699
  socklen_t len = static_cast<socklen_t>(sizeof(int));
2341
2700
  if(getsockopt(fd, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&val), &len) == SOCKET_ERROR)
2342
2701
  {
2343
- SocketException ex(__FILE__, __LINE__);
2344
- ex.error = getSocketErrno();
2345
- throw ex;
2702
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2346
2703
  }
2347
2704
 
2348
2705
  if(val > 0)
@@ -2354,21 +2711,15 @@ IceInternal::doFinishConnect(SOCKET fd)
2354
2711
  #endif
2355
2712
  if(connectionRefused())
2356
2713
  {
2357
- ConnectionRefusedException ex(__FILE__, __LINE__);
2358
- ex.error = getSocketErrno();
2359
- throw ex;
2714
+ throw ConnectionRefusedException(__FILE__, __LINE__, getSocketErrno());
2360
2715
  }
2361
2716
  else if(connectFailed())
2362
2717
  {
2363
- ConnectFailedException ex(__FILE__, __LINE__);
2364
- ex.error = getSocketErrno();
2365
- throw ex;
2718
+ throw ConnectFailedException(__FILE__, __LINE__, getSocketErrno());
2366
2719
  }
2367
2720
  else
2368
2721
  {
2369
- SocketException ex(__FILE__, __LINE__);
2370
- ex.error = getSocketErrno();
2371
- throw ex;
2722
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2372
2723
  }
2373
2724
  }
2374
2725
 
@@ -2383,9 +2734,7 @@ IceInternal::doFinishConnect(SOCKET fd)
2383
2734
  Address remoteAddr;
2384
2735
  if(fdToRemoteAddress(fd, remoteAddr) && compareAddress(remoteAddr, localAddr) == 0)
2385
2736
  {
2386
- ConnectionRefusedException ex(__FILE__, __LINE__);
2387
- ex.error = 0; // No appropriate errno
2388
- throw ex;
2737
+ throw ConnectionRefusedException(__FILE__, __LINE__, 0); // No appropriate errno
2389
2738
  }
2390
2739
  #endif
2391
2740
  }
@@ -2407,9 +2756,7 @@ repeatAccept:
2407
2756
  goto repeatAccept;
2408
2757
  }
2409
2758
 
2410
- SocketException ex(__FILE__, __LINE__);
2411
- ex.error = getSocketErrno();
2412
- throw ex;
2759
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2413
2760
  }
2414
2761
 
2415
2762
  setTcpNoDelay(ret);
@@ -2417,7 +2764,6 @@ repeatAccept:
2417
2764
  return ret;
2418
2765
  }
2419
2766
 
2420
-
2421
2767
  void
2422
2768
  IceInternal::createPipe(SOCKET fds[2])
2423
2769
  {
@@ -2491,9 +2837,7 @@ IceInternal::createPipe(SOCKET fds[2])
2491
2837
 
2492
2838
  if(::pipe(fds) != 0)
2493
2839
  {
2494
- SyscallException ex(__FILE__, __LINE__);
2495
- ex.error = getSystemErrno();
2496
- throw ex;
2840
+ throw SyscallException(__FILE__, __LINE__, getSocketErrno());
2497
2841
  }
2498
2842
 
2499
2843
  try
@@ -2521,23 +2865,19 @@ IceInternal::createPipe(SOCKET fds[2])
2521
2865
  #endif
2522
2866
  }
2523
2867
 
2524
- #else // ICE_OS_WINRT
2868
+ #else // ICE_OS_UWP
2525
2869
 
2526
2870
  void
2527
- IceInternal::checkConnectErrorCode(const char* file, int line, HRESULT herr, HostName^ host)
2871
+ IceInternal::checkConnectErrorCode(const char* file, int line, HRESULT herr)
2528
2872
  {
2529
2873
  if(herr == E_ACCESSDENIED)
2530
2874
  {
2531
- SocketException ex(file, line);
2532
- ex.error = static_cast<int>(herr);
2533
- throw ex;
2875
+ throw SocketException(file, line, static_cast<int>(herr));
2534
2876
  }
2535
2877
  SocketErrorStatus error = SocketError::GetStatus(herr);
2536
2878
  if(error == SocketErrorStatus::ConnectionRefused)
2537
2879
  {
2538
- ConnectionRefusedException ex(file, line);
2539
- ex.error = static_cast<int>(error);
2540
- throw ex;
2880
+ throw ConnectionRefusedException(file, line, static_cast<int>(error));
2541
2881
  }
2542
2882
  else if(error == SocketErrorStatus::NetworkDroppedConnectionOnReset ||
2543
2883
  error == SocketErrorStatus::ConnectionTimedOut ||
@@ -2546,26 +2886,15 @@ IceInternal::checkConnectErrorCode(const char* file, int line, HRESULT herr, Hos
2546
2886
  error == SocketErrorStatus::ConnectionResetByPeer ||
2547
2887
  error == SocketErrorStatus::SoftwareCausedConnectionAbort)
2548
2888
  {
2549
- ConnectFailedException ex(file, line);
2550
- ex.error = static_cast<int>(error);
2551
- throw ex;
2889
+ throw ConnectFailedException(file, line, static_cast<int>(error));
2552
2890
  }
2553
2891
  else if(error == SocketErrorStatus::HostNotFound)
2554
2892
  {
2555
- DNSException ex(file, line);
2556
- ex.error = static_cast<int>(error);
2557
- //
2558
- // Don't need to pass a wide string converter as the wide string come from
2559
- // Windows API.
2560
- //
2561
- ex.host = IceUtil::wstringToString(host->RawName->Data(), IceUtil::getProcessStringConverter());
2562
- throw ex;
2893
+ throw DNSException(file, line, static_cast<int>(error), "");
2563
2894
  }
2564
2895
  else
2565
2896
  {
2566
- SocketException ex(file, line);
2567
- ex.error = static_cast<int>(error);
2568
- throw ex;
2897
+ throw SocketException(file, line, static_cast<int>(error));
2569
2898
  }
2570
2899
  }
2571
2900
 
@@ -2574,33 +2903,53 @@ IceInternal::checkErrorCode(const char* file, int line, HRESULT herr)
2574
2903
  {
2575
2904
  if(herr == E_ACCESSDENIED)
2576
2905
  {
2577
- SocketException ex(file, line);
2578
- ex.error = static_cast<int>(herr);
2579
- throw ex;
2906
+ throw SocketException(file, line, static_cast<int>(herr));
2580
2907
  }
2581
2908
  SocketErrorStatus error = SocketError::GetStatus(herr);
2582
2909
  if(error == SocketErrorStatus::NetworkDroppedConnectionOnReset ||
2583
2910
  error == SocketErrorStatus::SoftwareCausedConnectionAbort ||
2584
2911
  error == SocketErrorStatus::ConnectionResetByPeer)
2585
2912
  {
2586
- ConnectionLostException ex(file, line);
2587
- ex.error = static_cast<int>(error);
2588
- throw ex;
2913
+ throw ConnectionLostException(file, line, static_cast<int>(error));
2589
2914
  }
2590
2915
  else if(error == SocketErrorStatus::HostNotFound)
2591
2916
  {
2592
- DNSException ex(file, line);
2593
- ex.error = static_cast<int>(error);
2594
- throw ex;
2917
+ throw DNSException(file, line, static_cast<int>(error), "");
2595
2918
  }
2596
2919
  else
2597
2920
  {
2598
- SocketException ex(file, line);
2599
- ex.error = static_cast<int>(error);
2600
- throw ex;
2921
+ throw SocketException(file, line, static_cast<int>(error));
2601
2922
  }
2602
2923
  }
2603
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
+ }
2604
2953
 
2605
2954
  #endif
2606
2955
 
@@ -2639,12 +2988,10 @@ IceInternal::doConnectAsync(SOCKET fd, const Address& addr, const Address& sourc
2639
2988
 
2640
2989
  if(::bind(fd, &bindAddr.sa, size) == SOCKET_ERROR)
2641
2990
  {
2642
- SocketException ex(__FILE__, __LINE__);
2643
- ex.error = getSocketErrno();
2644
- throw ex;
2991
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2645
2992
  }
2646
2993
 
2647
- LPFN_CONNECTEX ConnectEx = NULL; // a pointer to the 'ConnectEx()' function
2994
+ LPFN_CONNECTEX ConnectEx = ICE_NULLPTR; // a pointer to the 'ConnectEx()' function
2648
2995
  GUID GuidConnectEx = WSAID_CONNECTEX; // The Guid
2649
2996
  DWORD dwBytes;
2650
2997
  if(WSAIoctl(fd,
@@ -2654,12 +3001,10 @@ IceInternal::doConnectAsync(SOCKET fd, const Address& addr, const Address& sourc
2654
3001
  &ConnectEx,
2655
3002
  sizeof(ConnectEx),
2656
3003
  &dwBytes,
2657
- NULL,
2658
- NULL) == SOCKET_ERROR)
3004
+ ICE_NULLPTR,
3005
+ ICE_NULLPTR) == SOCKET_ERROR)
2659
3006
  {
2660
- SocketException ex(__FILE__, __LINE__);
2661
- ex.error = getSocketErrno();
2662
- throw ex;
3007
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2663
3008
  }
2664
3009
 
2665
3010
  if(!ConnectEx(fd, &addr.sa, size, 0, 0, 0, &info))
@@ -2668,21 +3013,15 @@ IceInternal::doConnectAsync(SOCKET fd, const Address& addr, const Address& sourc
2668
3013
  {
2669
3014
  if(connectionRefused())
2670
3015
  {
2671
- ConnectionRefusedException ex(__FILE__, __LINE__);
2672
- ex.error = getSocketErrno();
2673
- throw ex;
3016
+ throw ConnectionRefusedException(__FILE__, __LINE__, getSocketErrno());
2674
3017
  }
2675
3018
  else if(connectFailed())
2676
3019
  {
2677
- ConnectFailedException ex(__FILE__, __LINE__);
2678
- ex.error = getSocketErrno();
2679
- throw ex;
3020
+ throw ConnectFailedException(__FILE__, __LINE__, getSocketErrno());
2680
3021
  }
2681
3022
  else
2682
3023
  {
2683
- SocketException ex(__FILE__, __LINE__);
2684
- ex.error = getSocketErrno();
2685
- throw ex;
3024
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2686
3025
  }
2687
3026
  }
2688
3027
  }
@@ -2696,35 +3035,41 @@ IceInternal::doFinishConnectAsync(SOCKET fd, AsyncInfo& info)
2696
3035
  // failure to connect. The socket isn't closed by this method.
2697
3036
  //
2698
3037
 
2699
- if(static_cast<int>(info.count) == SOCKET_ERROR)
3038
+ if(info.error != ERROR_SUCCESS)
2700
3039
  {
2701
3040
  WSASetLastError(info.error);
2702
3041
  if(connectionRefused())
2703
3042
  {
2704
- ConnectionRefusedException ex(__FILE__, __LINE__);
2705
- ex.error = getSocketErrno();
2706
- throw ex;
3043
+ throw ConnectionRefusedException(__FILE__, __LINE__, getSocketErrno());
2707
3044
  }
2708
3045
  else if(connectFailed())
2709
3046
  {
2710
- ConnectFailedException ex(__FILE__, __LINE__);
2711
- ex.error = getSocketErrno();
2712
- throw ex;
3047
+ throw ConnectFailedException(__FILE__, __LINE__, getSocketErrno());
2713
3048
  }
2714
3049
  else
2715
3050
  {
2716
- SocketException ex(__FILE__, __LINE__);
2717
- ex.error = getSocketErrno();
2718
- throw ex;
3051
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2719
3052
  }
2720
3053
  }
2721
3054
 
2722
- if(setsockopt(fd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0) == SOCKET_ERROR)
3055
+ if(setsockopt(fd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, ICE_NULLPTR, 0) == SOCKET_ERROR)
2723
3056
  {
2724
- SocketException ex(__FILE__, __LINE__);
2725
- ex.error = getSocketErrno();
2726
- throw ex;
3057
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
2727
3058
  }
2728
3059
  }
2729
3060
  #endif
2730
3061
 
3062
+ bool
3063
+ IceInternal::isIpAddress(const string& name)
3064
+ {
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
+ in_addr addr;
3071
+ in6_addr addr6;
3072
+
3073
+ return inet_pton(AF_INET, name.c_str(), &addr) > 0 || inet_pton(AF_INET6, name.c_str(), &addr6) > 0;
3074
+ #endif
3075
+ }