1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253
|
From 146925c2404655dbb61b9a18e57692bfc18eb6c6 Mon Sep 17 00:00:00 2001
From: Amini Allight <amini.allight@protonmail.com>
Date: Wed, 12 Feb 2025 03:53:35 +0000
Subject: [PATCH 1/8] fixed incompatibility with Boost 1.87 due to use of
previously-deprecated now-removed functionality
---
SConstruct | 4 +-
docs/faq.dox | 12 +-
.../broadcast_server/broadcast_server.cpp | 2 +-
examples/debug_client/debug_client.cpp | 2 +-
examples/debug_server/debug_server.cpp | 2 +-
examples/echo_client/echo_client.cpp | 2 +-
examples/echo_server/echo_server.cpp | 2 +-
.../echo_server_both/echo_server_both.cpp | 8 +-
examples/echo_server_tls/echo_server_tls.cpp | 2 +-
.../CMakeLists.txt | 2 +-
.../SConscript | 4 +-
.../external_io_context.cpp} | 14 +-
.../tcp_echo_server.hpp | 12 +-
examples/print_client/print_client.cpp | 2 +-
.../print_client_tls/print_client_tls.cpp | 2 +-
examples/scratch_server/scratch_server.cpp | 2 +-
examples/sip_client/sip_client.cpp | 2 +-
.../telemetry_client/telemetry_client.cpp | 4 +-
.../telemetry_server/telemetry_server.cpp | 2 +-
examples/testee_client/testee_client.cpp | 2 +-
examples/testee_server/testee_server.cpp | 2 +-
test/endpoint/endpoint.cpp | 6 +-
test/transport/asio/timers.cpp | 8 +-
test/transport/integration.cpp | 27 ++-
tutorials/utility_server/step1.cpp | 2 +-
tutorials/utility_server/step2.cpp | 2 +-
tutorials/utility_server/utility_server.md | 8 +-
websocketpp/roles/server_endpoint.hpp | 4 +-
websocketpp/transport/asio/base.hpp | 2 +-
websocketpp/transport/asio/connection.hpp | 44 ++---
websocketpp/transport/asio/endpoint.hpp | 186 +++++++++---------
websocketpp/transport/asio/security/none.hpp | 16 +-
websocketpp/transport/asio/security/tls.hpp | 20 +-
websocketpp/transport/debug/endpoint.hpp | 2 +-
websocketpp/transport/iostream/endpoint.hpp | 2 +-
websocketpp/transport/stub/endpoint.hpp | 2 +-
36 files changed, 207 insertions(+), 210 deletions(-)
rename examples/{external_io_service => external_io_context}/CMakeLists.txt (87%)
rename examples/{external_io_service => external_io_context}/SConscript (72%)
rename examples/{external_io_service/external_io_service.cpp => external_io_context/external_io_context.cpp} (93%)
rename examples/{external_io_service => external_io_context}/tcp_echo_server.hpp (92%)
Index: websocketpp/SConstruct
===================================================================
--- websocketpp.orig/SConstruct
+++ websocketpp/SConstruct
@@ -273,8 +273,8 @@ subprotocol_server = SConscript('#/examp
# telemetry_server
telemetry_server = SConscript('#/examples/telemetry_server/SConscript',variant_dir = builddir + 'telemetry_server',duplicate = 0)
-# external_io_service
-external_io_service = SConscript('#/examples/external_io_service/SConscript',variant_dir = builddir + 'external_io_service',duplicate = 0)
+# external_io_context
+external_io_context = SConscript('#/examples/external_io_context/SConscript',variant_dir = builddir + 'external_io_context',duplicate = 0)
if not env['PLATFORM'].startswith('win'):
# iostream_server
Index: websocketpp/docs/faq.dox
===================================================================
--- websocketpp.orig/docs/faq.dox
+++ websocketpp/docs/faq.dox
@@ -29,19 +29,19 @@ Note: some browsers will allow the conne
### How do I cleanly exit an Asio transport based program
-The Asio transport based clients and servers use the Asio library's underlying `io_service` to handle asyncronous networking operations. The standard behavior of the io_service is to run until there are no async operations left and then return. WebSocket++, when using the Asio transport, behaves like a standard Asio application. If you want your WebSocket++/Asio based program to stop network operations and cleanly close all sockets you will want to do the following:
+The Asio transport based clients and servers use the Asio library's underlying `io_context` to handle asyncronous networking operations. The standard behavior of the io_context is to run until there are no async operations left and then return. WebSocket++, when using the Asio transport, behaves like a standard Asio application. If you want your WebSocket++/Asio based program to stop network operations and cleanly close all sockets you will want to do the following:
- For servers, call `websocketpp::transport::asio::endpoint::stop_listening` to initiate the closing of the server listening socket.
- For clients, if you have engaged perpetual mode with `websocketpp::transport::asio::endpoint::start_perpetual`, disable it with `websocketpp::transport::asio::endpoint::stop_perpetual`.
- For both, run `websocketpp::endpoint::close` or `websocketpp::connection::close` on all currently outstanding connections. This will initiate the WebSocket closing handshake for these connections
-- Wait. Asio is asyncronous. When the calls to the above methods (stop_listening, close, etc) complete the server *will still be listening*, the connections *will still be active* until the io_service gets around to asyncronously processing the socket and WebSocket protocol closing handshakes. The `io_service::run` method will exit cleanly and automatically when all operations are complete.
+- Wait. Asio is asyncronous. When the calls to the above methods (stop_listening, close, etc) complete the server *will still be listening*, the connections *will still be active* until the io_context gets around to asyncronously processing the socket and WebSocket protocol closing handshakes. The `io_context::run` method will exit cleanly and automatically when all operations are complete.
-__WARNING__: Asio's `io_service` has a method called `stop`. WebSocket++ wraps this method as `websocketpp::transport::asio::endpoint::stop`. While this operation has a benign sounding name, it is a powerful and destructive operation that should only be used in special cases. If you are using `io_service::stop` or `endpoint::stop` without a very good reason your program is likely broken and may exhibit erratic behavior. Specifically, `io_service::stop` stops the processing of events entirely. This does not give current operations (such as socket closing handshakes) the opportunity to finish. It will leave your sockets in a dangling state that may invoke operating system level timeouts or other errors.
+__WARNING__: Asio's `io_context` has a method called `stop`. WebSocket++ wraps this method as `websocketpp::transport::asio::endpoint::stop`. While this operation has a benign sounding name, it is a powerful and destructive operation that should only be used in special cases. If you are using `io_context::stop` or `endpoint::stop` without a very good reason your program is likely broken and may exhibit erratic behavior. Specifically, `io_context::stop` stops the processing of events entirely. This does not give current operations (such as socket closing handshakes) the opportunity to finish. It will leave your sockets in a dangling state that may invoke operating system level timeouts or other errors.
__Special cases__:
-- If your client uses the `start_perpetual` method it will prevent the io_service from exiting even if it has nothing to do. This is useful if you want a client endpoint to idle in the background to allow new connections to be formed on demand rather than generating a new endpoint for each.
-- If you are using an external io_service and/or are placing non-WebSocket++ operations on the `io_service` those operations may keep the `io_service` open even after all WebSocket++ operations have completed.
-- If you are using `poll`/`poll_one`/`run_one` or otherwise manually driving the `io_service` event loop you may need to adjust usage to make sure you are correctly recognizing the "done with work" and "not done but idling / `io_service::work`" cases.
+- If your client uses the `start_perpetual` method it will prevent the io_context from exiting even if it has nothing to do. This is useful if you want a client endpoint to idle in the background to allow new connections to be formed on demand rather than generating a new endpoint for each.
+- If you are using an external io_context and/or are placing non-WebSocket++ operations on the `io_context` those operations may keep the `io_context` open even after all WebSocket++ operations have completed.
+- If you are using `poll`/`poll_one`/`run_one` or otherwise manually driving the `io_context` event loop you may need to adjust usage to make sure you are correctly recognizing the "done with work" and "not done but idling / `io_context::work`" cases.
### Is there a way to check the validity of a `connection_hdl`?
Index: websocketpp/examples/broadcast_server/broadcast_server.cpp
===================================================================
--- websocketpp.orig/examples/broadcast_server/broadcast_server.cpp
+++ websocketpp/examples/broadcast_server/broadcast_server.cpp
@@ -75,7 +75,7 @@ public:
return;
}
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
//try {
m_server.run();
//} catch (const std::exception & e) {
Index: websocketpp/examples/debug_client/debug_client.cpp
===================================================================
--- websocketpp.orig/examples/debug_client/debug_client.cpp
+++ websocketpp/examples/debug_client/debug_client.cpp
@@ -43,7 +43,7 @@ using websocketpp::lib::bind;
// pull out the type of messages sent by our config
typedef websocketpp::config::asio_tls_client::message_type::ptr message_ptr;
-typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context> context_ptr;
+typedef websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context> context_ptr;
typedef client::connection_ptr connection_ptr;
@@ -82,7 +82,7 @@ public:
m_endpoint.connect(con);
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
m_start = std::chrono::high_resolution_clock::now();
m_endpoint.run();
}
@@ -93,13 +93,13 @@ public:
context_ptr on_tls_init(websocketpp::connection_hdl) {
m_tls_init = std::chrono::high_resolution_clock::now();
- context_ptr ctx = websocketpp::lib::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::tlsv1);
+ context_ptr ctx = websocketpp::lib::make_shared<websocketpp::lib::asio::ssl::context>(websocketpp::lib::asio::ssl::context::tlsv1);
try {
- ctx->set_options(boost::asio::ssl::context::default_workarounds |
- boost::asio::ssl::context::no_sslv2 |
- boost::asio::ssl::context::no_sslv3 |
- boost::asio::ssl::context::single_dh_use);
+ ctx->set_options(websocketpp::lib::asio::ssl::context::default_workarounds |
+ websocketpp::lib::asio::ssl::context::no_sslv2 |
+ websocketpp::lib::asio::ssl::context::no_sslv3 |
+ websocketpp::lib::asio::ssl::context::single_dh_use);
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
}
Index: websocketpp/examples/debug_server/debug_server.cpp
===================================================================
--- websocketpp.orig/examples/debug_server/debug_server.cpp
+++ websocketpp/examples/debug_server/debug_server.cpp
@@ -162,7 +162,7 @@ int main() {
// Start the server accept loop
echo_server.start_accept();
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
echo_server.run();
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
Index: websocketpp/examples/echo_client/echo_client.cpp
===================================================================
--- websocketpp.orig/examples/echo_client/echo_client.cpp
+++ websocketpp/examples/echo_client/echo_client.cpp
@@ -87,7 +87,7 @@ int main(int argc, char* argv[]) {
// exchanged until the event loop starts running in the next line.
c.connect(con);
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
// this will cause a single connection to be made to the server. c.run()
// will exit when this connection is closed.
c.run();
Index: websocketpp/examples/echo_server/echo_server.cpp
===================================================================
--- websocketpp.orig/examples/echo_server/echo_server.cpp
+++ websocketpp/examples/echo_server/echo_server.cpp
@@ -62,7 +62,7 @@ int main() {
// Start the server accept loop
echo_server.start_accept(&on_end_accept);
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
echo_server.run();
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
Index: websocketpp/examples/echo_server_both/echo_server_both.cpp
===================================================================
--- websocketpp.orig/examples/echo_server_both/echo_server_both.cpp
+++ websocketpp/examples/echo_server_both/echo_server_both.cpp
@@ -15,7 +15,7 @@ using websocketpp::lib::bind;
using websocketpp::lib::error_code;
// type of the ssl context pointer is long so alias it
-typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context> context_ptr;
+typedef websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context> context_ptr;
// The shared on_message handler takes a template parameter so the function can
// resolve any endpoint dependent types like message_ptr or connection_ptr
@@ -48,16 +48,16 @@ std::string get_password() {
context_ptr on_tls_init(websocketpp::connection_hdl hdl) {
std::cout << "on_tls_init called with hdl: " << hdl.lock().get() << std::endl;
- context_ptr ctx(new boost::asio::ssl::context(boost::asio::ssl::context::tlsv1));
+ context_ptr ctx(new websocketpp::lib::asio::ssl::context(websocketpp::lib::asio::ssl::context::tlsv1));
try {
- ctx->set_options(boost::asio::ssl::context::default_workarounds |
- boost::asio::ssl::context::no_sslv2 |
- boost::asio::ssl::context::no_sslv3 |
- boost::asio::ssl::context::single_dh_use);
+ ctx->set_options(websocketpp::lib::asio::ssl::context::default_workarounds |
+ websocketpp::lib::asio::ssl::context::no_sslv2 |
+ websocketpp::lib::asio::ssl::context::no_sslv3 |
+ websocketpp::lib::asio::ssl::context::single_dh_use);
ctx->set_password_callback(bind(&get_password));
ctx->use_certificate_chain_file("server.pem");
- ctx->use_private_key_file("server.pem", boost::asio::ssl::context::pem);
+ ctx->use_private_key_file("server.pem", websocketpp::lib::asio::ssl::context::pem);
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
}
@@ -65,14 +65,14 @@ context_ptr on_tls_init(websocketpp::con
}
int main() {
- // set up an external io_service to run both endpoints on. This is not
+ // set up an external io_context to run both endpoints on. This is not
// strictly necessary, but simplifies thread management a bit.
- boost::asio::io_service ios;
+ websocketpp::lib::asio::io_context ctx;
// set up plain endpoint
server_plain endpoint_plain;
- // initialize asio with our external io_service rather than an internal one
- endpoint_plain.init_asio(&ios);
+ // initialize asio with our external io_context rather than an internal one
+ endpoint_plain.init_asio(&ctx);
endpoint_plain.set_message_handler(
bind(&on_message<server_plain>,&endpoint_plain,::_1,::_2));
endpoint_plain.listen(80);
@@ -80,7 +80,7 @@ int main() {
// set up tls endpoint
server_tls endpoint_tls;
- endpoint_tls.init_asio(&ios);
+ endpoint_tls.init_asio(&ctx);
endpoint_tls.set_message_handler(
bind(&on_message<server_tls>,&endpoint_tls,::_1,::_2));
// TLS endpoint has an extra handler for the tls init
@@ -89,6 +89,6 @@ int main() {
endpoint_tls.listen(443);
endpoint_tls.start_accept(&on_end_accept);
- // Start the ASIO io_service run loop running both endpoints
- ios.run();
+ // Start the ASIO io_context run loop running both endpoints
+ ctx.run();
}
Index: websocketpp/examples/echo_server_tls/echo_server_tls.cpp
===================================================================
--- websocketpp.orig/examples/echo_server_tls/echo_server_tls.cpp
+++ websocketpp/examples/echo_server_tls/echo_server_tls.cpp
@@ -155,7 +155,7 @@ int main() {
// Start the server accept loop
echo_server.start_accept(&on_end_accept);
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
echo_server.run();
}
Index: websocketpp/examples/external_io_service/CMakeLists.txt
===================================================================
--- websocketpp.orig/examples/external_io_service/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-
-file (GLOB SOURCE_FILES *.cpp)
-file (GLOB HEADER_FILES *.hpp)
-
-init_target (external_io_service)
-
-build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
-
-link_boost ()
-final_target ()
-
-set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
Index: websocketpp/examples/external_io_context/CMakeLists.txt
===================================================================
--- /dev/null
+++ websocketpp/examples/external_io_context/CMakeLists.txt
@@ -0,0 +1,12 @@
+
+file (GLOB SOURCE_FILES *.cpp)
+file (GLOB HEADER_FILES *.hpp)
+
+init_target (external_io_context)
+
+build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
+
+link_boost ()
+final_target ()
+
+set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
Index: websocketpp/examples/external_io_service/SConscript
===================================================================
--- websocketpp.orig/examples/external_io_service/SConscript
+++ /dev/null
@@ -1,23 +0,0 @@
-## Main development example
-##
-
-Import('env')
-Import('env_cpp11')
-Import('boostlibs')
-Import('platform_libs')
-Import('polyfill_libs')
-
-env = env.Clone ()
-env_cpp11 = env_cpp11.Clone ()
-
-prgs = []
-
-# if a C++11 environment is available build using that, otherwise use boost
-if 'WSPP_CPP11_ENABLED' in env_cpp11:
- ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
- prgs += env_cpp11.Program('external_io_service', ["external_io_service.cpp"], LIBS = ALL_LIBS)
-else:
- ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs]
- prgs += env.Program('external_io_service', ["external_io_service.cpp"], LIBS = ALL_LIBS)
-
-Return('prgs')
Index: websocketpp/examples/external_io_context/SConscript
===================================================================
--- /dev/null
+++ websocketpp/examples/external_io_context/SConscript
@@ -0,0 +1,23 @@
+## Main development example
+##
+
+Import('env')
+Import('env_cpp11')
+Import('boostlibs')
+Import('platform_libs')
+Import('polyfill_libs')
+
+env = env.Clone ()
+env_cpp11 = env_cpp11.Clone ()
+
+prgs = []
+
+# if a C++11 environment is available build using that, otherwise use boost
+if 'WSPP_CPP11_ENABLED' in env_cpp11:
+ ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
+ prgs += env_cpp11.Program('external_io_context', ["external_io_context.cpp"], LIBS = ALL_LIBS)
+else:
+ ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs]
+ prgs += env.Program('external_io_context', ["external_io_context.cpp"], LIBS = ALL_LIBS)
+
+Return('prgs')
Index: websocketpp/examples/external_io_service/external_io_service.cpp
===================================================================
--- websocketpp.orig/examples/external_io_service/external_io_service.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2015, Peter Thorson. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the WebSocket++ Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "tcp_echo_server.hpp"
-
-#include <websocketpp/config/asio_no_tls.hpp>
-#include <websocketpp/server.hpp>
-
-#include <iostream>
-
-using websocketpp::lib::placeholders::_1;
-using websocketpp::lib::placeholders::_2;
-using websocketpp::lib::bind;
-using websocketpp::lib::error_code;
-
-typedef websocketpp::server<websocketpp::config::asio> ws_echo_server;
-
-// Define a callback to handle incoming messages
-void on_message(ws_echo_server* s, websocketpp::connection_hdl hdl, ws_echo_server::message_ptr msg) {
- std::cout << "on_message called with hdl: " << hdl.lock().get()
- << " and message: " << msg->get_payload()
- << std::endl;
-
- // check for a special command to instruct the server to stop listening so
- // it can be cleanly exited.
- if (msg->get_payload() == "stop-listening") {
- s->stop_listening();
- return;
- }
-
- try {
- s->send(hdl, msg->get_payload(), msg->get_opcode());
- } catch (websocketpp::exception const & e) {
- std::cout << "Echo failed because: "
- << "(" << e.what() << ")" << std::endl;
- }
-}
-
-// Define a callback to handle failures accepting connections
-void on_end_accept(error_code lib_ec, error_code trans_ec) {
- std::cout << "Accept loop ended "
- << lib_ec.message() << "/" << trans_ec.message() << std::endl;
-}
-
-int main() {
- asio::io_service service;
-
- // Add a TCP echo server on port 9003
- tcp_echo_server custom_http_server(service, 9003);
-
- // Add a WebSocket echo server on port 9002
- ws_echo_server ws_server;
- ws_server.set_access_channels(websocketpp::log::alevel::all);
- ws_server.clear_access_channels(websocketpp::log::alevel::frame_payload);
-
- // The only difference in this code between an internal and external
- // io_service is the different constructor to init_asio
- ws_server.init_asio(&service);
-
- // Register our message handler
- ws_server.set_message_handler(bind(&on_message,&ws_server,::_1,::_2));
- ws_server.listen(9002);
- ws_server.start_accept(&on_end_accept);
-
- // TODO: add a timer?
-
- // Start the Asio io_service run loop for all
- service.run();
-}
\ No newline at end of file
Index: websocketpp/examples/external_io_context/external_io_context.cpp
===================================================================
--- /dev/null
+++ websocketpp/examples/external_io_context/external_io_context.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2015, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tcp_echo_server.hpp"
+
+#include <websocketpp/config/asio_no_tls.hpp>
+#include <websocketpp/server.hpp>
+
+#include <iostream>
+
+using websocketpp::lib::placeholders::_1;
+using websocketpp::lib::placeholders::_2;
+using websocketpp::lib::bind;
+using websocketpp::lib::error_code;
+
+typedef websocketpp::server<websocketpp::config::asio> ws_echo_server;
+
+// Define a callback to handle incoming messages
+void on_message(ws_echo_server* s, websocketpp::connection_hdl hdl, ws_echo_server::message_ptr msg) {
+ std::cout << "on_message called with hdl: " << hdl.lock().get()
+ << " and message: " << msg->get_payload()
+ << std::endl;
+
+ // check for a special command to instruct the server to stop listening so
+ // it can be cleanly exited.
+ if (msg->get_payload() == "stop-listening") {
+ s->stop_listening();
+ return;
+ }
+
+ try {
+ s->send(hdl, msg->get_payload(), msg->get_opcode());
+ } catch (websocketpp::exception const & e) {
+ std::cout << "Echo failed because: "
+ << "(" << e.what() << ")" << std::endl;
+ }
+}
+
+// Define a callback to handle failures accepting connections
+void on_end_accept(error_code lib_ec, error_code trans_ec) {
+ std::cout << "Accept loop ended "
+ << lib_ec.message() << "/" << trans_ec.message() << std::endl;
+}
+
+int main() {
+ websocketpp::lib::asio::io_context context;
+
+ // Add a TCP echo server on port 9003
+ tcp_echo_server custom_http_server(context, 9003);
+
+ // Add a WebSocket echo server on port 9002
+ ws_echo_server ws_server;
+ ws_server.set_access_channels(websocketpp::log::alevel::all);
+ ws_server.clear_access_channels(websocketpp::log::alevel::frame_payload);
+
+ // The only difference in this code between an internal and external
+ // io_context is the different constructor to init_asio
+ ws_server.init_asio(&context);
+
+ // Register our message handler
+ ws_server.set_message_handler(bind(&on_message,&ws_server,::_1,::_2));
+ ws_server.listen(9002);
+ ws_server.start_accept(&on_end_accept);
+
+ // TODO: add a timer?
+
+ // Start the Asio io_context run loop for all
+ context.run();
+}
Index: websocketpp/examples/external_io_service/tcp_echo_server.hpp
===================================================================
--- websocketpp.orig/examples/external_io_service/tcp_echo_server.hpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2015, Peter Thorson. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the WebSocket++ Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * TCP Echo Server
- *
- * This file defines a simple TCP Echo Server. It is adapted from the Asio
- * example: cpp03/echo/async_tcp_echo_server.cpp
- */
-
-#include <websocketpp/common/asio.hpp>
-#include <websocketpp/common/memory.hpp>
-#include <websocketpp/common/functional.hpp>
-
-using websocketpp::lib::placeholders::_1;
-using websocketpp::lib::placeholders::_2;
-using websocketpp::lib::bind;
-
-namespace asio = websocketpp::lib::asio;
-
-struct tcp_echo_session : websocketpp::lib::enable_shared_from_this<tcp_echo_session> {
- typedef websocketpp::lib::shared_ptr<tcp_echo_session> ptr;
-
- tcp_echo_session(asio::io_service & service) : m_socket(service) {}
-
- void start() {
- m_socket.async_read_some(asio::buffer(m_buffer, sizeof(m_buffer)),
- websocketpp::lib::bind(
- &tcp_echo_session::handle_read, shared_from_this(), _1, _2));
- }
-
- void handle_read(const asio::error_code & ec, size_t transferred) {
- if (!ec) {
- asio::async_write(m_socket,
- asio::buffer(m_buffer, transferred),
- bind(&tcp_echo_session::handle_write, shared_from_this(), _1));
- }
- }
-
- void handle_write(const asio::error_code & ec) {
- if (!ec) {
- m_socket.async_read_some(asio::buffer(m_buffer, sizeof(m_buffer)),
- bind(&tcp_echo_session::handle_read, shared_from_this(), _1, _2));
- }
- }
-
- asio::ip::tcp::socket m_socket;
- char m_buffer[1024];
-};
-
-struct tcp_echo_server {
- tcp_echo_server(asio::io_service & service, short port)
- : m_service(service)
- , m_acceptor(service, asio::ip::tcp::endpoint(asio::ip::tcp::v6(), port))
- {
- this->start_accept();
- }
-
- void start_accept() {
- tcp_echo_session::ptr new_session(new tcp_echo_session(m_service));
- m_acceptor.async_accept(new_session->m_socket,
- bind(&tcp_echo_server::handle_accept, this, new_session, _1));
- }
-
- void handle_accept(tcp_echo_session::ptr new_session, const asio::error_code & ec) {
- if (!ec) {
- new_session->start();
- }
- start_accept();
- }
-
- asio::io_service & m_service;
- asio::ip::tcp::acceptor m_acceptor;
-};
Index: websocketpp/examples/external_io_context/tcp_echo_server.hpp
===================================================================
--- /dev/null
+++ websocketpp/examples/external_io_context/tcp_echo_server.hpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2015, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * TCP Echo Server
+ *
+ * This file defines a simple TCP Echo Server. It is adapted from the Asio
+ * example: cpp03/echo/async_tcp_echo_server.cpp
+ */
+
+#include <websocketpp/common/asio.hpp>
+#include <websocketpp/common/memory.hpp>
+#include <websocketpp/common/functional.hpp>
+
+using websocketpp::lib::placeholders::_1;
+using websocketpp::lib::placeholders::_2;
+using websocketpp::lib::bind;
+
+struct tcp_echo_session : websocketpp::lib::enable_shared_from_this<tcp_echo_session> {
+ typedef websocketpp::lib::shared_ptr<tcp_echo_session> ptr;
+
+ tcp_echo_session(websocketpp::lib::asio::io_context & context) : m_socket(context) {}
+
+ void start() {
+ m_socket.async_read_some(websocketpp::lib::asio::buffer(m_buffer, sizeof(m_buffer)),
+ websocketpp::lib::bind(
+ &tcp_echo_session::handle_read, shared_from_this(), _1, _2));
+ }
+
+ void handle_read(const websocketpp::lib::asio::error_code & ec, size_t transferred) {
+ if (!ec) {
+ websocketpp::lib::asio::async_write(m_socket,
+ websocketpp::lib::asio::buffer(m_buffer, transferred),
+ bind(&tcp_echo_session::handle_write, shared_from_this(), _1));
+ }
+ }
+
+ void handle_write(const websocketpp::lib::asio::error_code & ec) {
+ if (!ec) {
+ m_socket.async_read_some(websocketpp::lib::asio::buffer(m_buffer, sizeof(m_buffer)),
+ bind(&tcp_echo_session::handle_read, shared_from_this(), _1, _2));
+ }
+ }
+
+ websocketpp::lib::asio::ip::tcp::socket m_socket;
+ char m_buffer[1024];
+};
+
+struct tcp_echo_server {
+ tcp_echo_server(websocketpp::lib::asio::io_context & context, short port)
+ : m_context(context)
+ , m_acceptor(context, websocketpp::lib::asio::ip::tcp::endpoint(websocketpp::lib::asio::ip::tcp::v6(), port))
+ {
+ this->start_accept();
+ }
+
+ void start_accept() {
+ tcp_echo_session::ptr new_session(new tcp_echo_session(m_context));
+ m_acceptor.async_accept(new_session->m_socket,
+ bind(&tcp_echo_server::handle_accept, this, new_session, _1));
+ }
+
+ void handle_accept(tcp_echo_session::ptr new_session, const websocketpp::lib::asio::error_code & ec) {
+ if (!ec) {
+ new_session->start();
+ }
+ start_accept();
+ }
+
+ websocketpp::lib::asio::io_context & m_context;
+ websocketpp::lib::asio::ip::tcp::acceptor m_acceptor;
+};
Index: websocketpp/examples/print_client/print_client.cpp
===================================================================
--- websocketpp.orig/examples/print_client/print_client.cpp
+++ websocketpp/examples/print_client/print_client.cpp
@@ -68,7 +68,7 @@ int main(int argc, char* argv[]) {
// exchanged until the event loop starts running in the next line.
c.connect(con);
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
// this will cause a single connection to be made to the server. c.run()
// will exit when this connection is closed.
c.run();
Index: websocketpp/examples/print_client_tls/print_client_tls.cpp
===================================================================
--- websocketpp.orig/examples/print_client_tls/print_client_tls.cpp
+++ websocketpp/examples/print_client_tls/print_client_tls.cpp
@@ -112,7 +112,7 @@ bool verify_common_name(char const * hos
* and
* https://github.com/iSECPartners/ssl-conservatory
*/
-bool verify_certificate(const char * hostname, bool preverified, boost::asio::ssl::verify_context& ctx) {
+bool verify_certificate(const char * hostname, bool preverified, websocketpp::lib::asio::ssl::verify_context& ctx) {
// The verify callback can be used to check whether the certificate that is
// being presented is valid for the peer. For example, RFC 2818 describes
// the steps involved in doing this for HTTPS. Consult the OpenSSL
@@ -176,16 +176,16 @@ bool verify_certificate(const char * hos
* (websocketpp.org, for example).
*/
context_ptr on_tls_init(const char * hostname, websocketpp::connection_hdl) {
- context_ptr ctx = websocketpp::lib::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::sslv23);
+ context_ptr ctx = websocketpp::lib::make_shared<websocketpp::lib::asio::ssl::context>(websocketpp::lib::asio::ssl::context::sslv23);
try {
- ctx->set_options(boost::asio::ssl::context::default_workarounds |
- boost::asio::ssl::context::no_sslv2 |
- boost::asio::ssl::context::no_sslv3 |
- boost::asio::ssl::context::single_dh_use);
+ ctx->set_options(websocketpp::lib::asio::ssl::context::default_workarounds |
+ websocketpp::lib::asio::ssl::context::no_sslv2 |
+ websocketpp::lib::asio::ssl::context::no_sslv3 |
+ websocketpp::lib::asio::ssl::context::single_dh_use);
- ctx->set_verify_mode(boost::asio::ssl::verify_peer);
+ ctx->set_verify_mode(websocketpp::lib::asio::ssl::verify_peer);
ctx->set_verify_callback(bind(&verify_certificate, hostname, ::_1, ::_2));
// Here we load the CA certificates of all CA's that this client trusts.
@@ -239,7 +239,7 @@ int main(int argc, char* argv[]) {
c.get_alog().write(websocketpp::log::alevel::app, "Connecting to " + uri);
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
// this will cause a single connection to be made to the server. c.run()
// will exit when this connection is closed.
c.run();
Index: websocketpp/examples/scratch_server/scratch_server.cpp
===================================================================
--- websocketpp.orig/examples/scratch_server/scratch_server.cpp
+++ websocketpp/examples/scratch_server/scratch_server.cpp
@@ -94,7 +94,7 @@ int main(int argc, char * argv[]) {
// Start the server accept loop
echo_server.start_accept();
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
echo_server.run();
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
Index: websocketpp/examples/sip_client/sip_client.cpp
===================================================================
--- websocketpp.orig/examples/sip_client/sip_client.cpp
+++ websocketpp/examples/sip_client/sip_client.cpp
@@ -69,7 +69,7 @@ int main(int argc, char* argv[]) {
sip_client.connect(con);
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
sip_client.run();
while(!received) {
Index: websocketpp/examples/telemetry_client/telemetry_client.cpp
===================================================================
--- websocketpp.orig/examples/telemetry_client/telemetry_client.cpp
+++ websocketpp/examples/telemetry_client/telemetry_client.cpp
@@ -62,10 +62,10 @@ public:
m_hdl = con->get_handle();
// Queue the connection. No DNS queries or network connections will be
- // made until the io_service event loop is run.
+ // made until the io_context event loop is run.
m_client.connect(con);
- // Create a thread to run the ASIO io_service event loop
+ // Create a thread to run the ASIO io_context event loop
websocketpp::lib::thread asio_thread(&client::run, &m_client);
// Create a thread to run the telemetry loop
Index: websocketpp/examples/telemetry_server/telemetry_server.cpp
===================================================================
--- websocketpp.orig/examples/telemetry_server/telemetry_server.cpp
+++ websocketpp/examples/telemetry_server/telemetry_server.cpp
@@ -69,7 +69,7 @@ public:
// Set the initial timer to start telemetry
set_timer();
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
try {
m_endpoint.run();
} catch (websocketpp::exception const & e) {
Index: websocketpp/examples/testee_client/testee_client.cpp
===================================================================
--- websocketpp.orig/examples/testee_client/testee_client.cpp
+++ websocketpp/examples/testee_client/testee_client.cpp
@@ -117,7 +117,7 @@ int main(int argc, char* argv[]) {
client::connection_ptr con = c.get_connection(uri+"/getCaseCount", ec);
c.connect(con);
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
c.run();
std::cout << "case count: " << case_count << std::endl;
Index: websocketpp/examples/testee_server/testee_server.cpp
===================================================================
--- websocketpp.orig/examples/testee_server/testee_server.cpp
+++ websocketpp/examples/testee_server/testee_server.cpp
@@ -88,8 +88,8 @@ void on_message(server* s, websocketpp::
s->send(hdl, msg->get_payload(), msg->get_opcode());
}
-void on_socket_init(websocketpp::connection_hdl, boost::asio::ip::tcp::socket & s) {
- boost::asio::ip::tcp::no_delay option(true);
+void on_socket_init(websocketpp::connection_hdl, websocketpp::lib::asio::ip::tcp::socket & s) {
+ websocketpp::lib::asio::ip::tcp::no_delay option(true);
s.set_option(option);
}
@@ -131,7 +131,7 @@ int main(int argc, char * argv[]) {
// Start the server accept loop
testee_server.start_accept(&on_end_accept);
- // Start the ASIO io_service run loop
+ // Start the ASIO io_context run loop
if (num_threads == 1) {
testee_server.run();
} else {
Index: websocketpp/test/endpoint/endpoint.cpp
===================================================================
--- websocketpp.orig/test/endpoint/endpoint.cpp
+++ websocketpp/test/endpoint/endpoint.cpp
@@ -53,8 +53,8 @@ BOOST_AUTO_TEST_CASE( initialize_server_
BOOST_AUTO_TEST_CASE( initialize_server_asio_external ) {
websocketpp::server<websocketpp::config::asio> s;
- boost::asio::io_service ios;
- s.init_asio(&ios);
+ websocketpp::lib::asio::io_context ctx;
+ s.init_asio(&ctx);
}
#ifdef _WEBSOCKETPP_MOVE_SEMANTICS_
@@ -141,8 +141,8 @@ BOOST_AUTO_TEST_CASE( listen_after_liste
server1.init_asio();
server2.init_asio();
- boost::asio::ip::tcp::endpoint ep1(boost::asio::ip::address::from_string("127.0.0.1"), 12345);
- boost::asio::ip::tcp::endpoint ep2(boost::asio::ip::address::from_string("127.0.0.1"), 23456);
+ websocketpp::lib::asio::ip::tcp::endpoint ep1(websocketpp::lib::asio::ip::make_address("127.0.0.1"), 12345);
+ websocketpp::lib::asio::ip::tcp::endpoint ep2(websocketpp::lib::asio::ip::make_address("127.0.0.1"), 23456);
server1.listen(ep1, ec);
BOOST_CHECK(!ec);
Index: websocketpp/test/transport/asio/timers.cpp
===================================================================
--- websocketpp.orig/test/transport/asio/timers.cpp
+++ websocketpp/test/transport/asio/timers.cpp
@@ -54,9 +54,9 @@ void run_dummy_server(int port) {
using boost::asio::ip::tcp;
try {
- boost::asio::io_service io_service;
- tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v6(), port));
- tcp::socket socket(io_service);
+ boost::asio::io_context io_context;
+ tcp::acceptor acceptor(io_context, tcp::endpoint(tcp::v6(), port));
+ tcp::socket socket(io_context);
acceptor.accept(socket);
for (;;) {
@@ -79,8 +79,9 @@ void run_dummy_server(int port) {
// Wait for the specified time period then fail the test
void run_test_timer(long value) {
- boost::asio::io_service ios;
- boost::asio::deadline_timer t(ios,boost::posix_time::milliseconds(value));
+ boost::asio::io_context ctx;
+ boost::asio::system_timer t(ctx);
+ t.expires_after(std::chrono::milliseconds(value));
boost::system::error_code ec;
t.wait(ec);
BOOST_FAIL( "Test timed out" );
@@ -106,9 +107,9 @@ struct config {
};
// Mock context that does no validation
-typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context> context_ptr;
+typedef websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context> context_ptr;
context_ptr on_tls_init(websocketpp::connection_hdl) {
- return context_ptr(new boost::asio::ssl::context(boost::asio::ssl::context::sslv23));
+ return context_ptr(new websocketpp::lib::asio::ssl::context(websocketpp::lib::asio::ssl::context::sslv23));
}
// Mock connection
Index: websocketpp/test/transport/integration.cpp
===================================================================
--- websocketpp.orig/test/transport/integration.cpp
+++ websocketpp/test/transport/integration.cpp
@@ -38,6 +38,8 @@
#include <websocketpp/server.hpp>
#include <websocketpp/client.hpp>
+#include "boost/date_time/posix_time/posix_time.hpp"
+
struct config : public websocketpp::config::asio_client {
typedef config type;
typedef websocketpp::config::asio base;
@@ -218,19 +220,19 @@ void run_time_limited_client(client & c,
}
void run_dummy_server(int port) {
- using boost::asio::ip::tcp;
+ using websocketpp::lib::asio::ip::tcp;
try {
- boost::asio::io_service io_service;
- tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v6(), port));
- tcp::socket socket(io_service);
+ websocketpp::lib::asio::io_context io_context;
+ tcp::acceptor acceptor(io_context, tcp::endpoint(tcp::v6(), port));
+ tcp::socket socket(io_context);
acceptor.accept(socket);
for (;;) {
char data[512];
- boost::system::error_code ec;
- socket.read_some(boost::asio::buffer(data), ec);
- if (ec == boost::asio::error::eof) {
+ websocketpp::lib::asio::error_code ec;
+ socket.read_some(websocketpp::lib::asio::buffer(data), ec);
+ if (ec == websocketpp::lib::asio::error::eof) {
break;
} else if (ec) {
// other error
@@ -239,27 +241,26 @@ void run_dummy_server(int port) {
}
} catch (std::exception & e) {
std::cout << e.what() << std::endl;
- } catch (boost::system::error_code & ec) {
+ } catch (websocketpp::lib::asio::error_code & ec) {
std::cout << ec.message() << std::endl;
}
}
void run_dummy_client(std::string port) {
- using boost::asio::ip::tcp;
+ using websocketpp::lib::asio::ip::tcp;
try {
- boost::asio::io_service io_service;
- tcp::resolver resolver(io_service);
- tcp::resolver::query query("localhost", port);
- tcp::resolver::iterator iterator = resolver.resolve(query);
- tcp::socket socket(io_service);
+ websocketpp::lib::asio::io_context io_context;
+ tcp::resolver resolver(io_context);
+ tcp::resolver::results_type results = resolver.resolve("localhost", port);
+ tcp::socket socket(io_context);
- boost::asio::connect(socket, iterator);
+ websocketpp::lib::asio::connect(socket, results);
for (;;) {
char data[512];
- boost::system::error_code ec;
- socket.read_some(boost::asio::buffer(data), ec);
- if (ec == boost::asio::error::eof) {
+ websocketpp::lib::asio::error_code ec;
+ socket.read_some(websocketpp::lib::asio::buffer(data), ec);
+ if (ec == websocketpp::lib::asio::error::eof) {
break;
} else if (ec) {
// other error
@@ -268,7 +269,7 @@ void run_dummy_client(std::string port)
}
} catch (std::exception & e) {
std::cout << e.what() << std::endl;
- } catch (boost::system::error_code & ec) {
+ } catch (websocketpp::lib::asio::error_code & ec) {
std::cout << ec.message() << std::endl;
}
}
@@ -354,33 +355,34 @@ void close(T * e, websocketpp::connectio
e->get_con_from_hdl(hdl)->close(websocketpp::close::status::normal,"");
}
-class test_deadline_timer
+class test_system_timer
{
public:
- test_deadline_timer(int seconds)
- : m_timer(m_io_service, boost::posix_time::seconds(seconds))
+ test_system_timer(int seconds)
+ : m_timer(m_io_context)
{
- m_timer.async_wait(bind(&test_deadline_timer::expired, this, ::_1));
- std::size_t (boost::asio::io_service::*run)() = &boost::asio::io_service::run;
- m_timer_thread = websocketpp::lib::thread(websocketpp::lib::bind(run, &m_io_service));
+ m_timer.expires_after(std::chrono::seconds(seconds));
+ m_timer.async_wait(bind(&test_system_timer::expired, this, ::_1));
+ std::size_t (websocketpp::lib::asio::io_context::*run)() = &websocketpp::lib::asio::io_context::run;
+ m_timer_thread = websocketpp::lib::thread(websocketpp::lib::bind(run, &m_io_context));
}
- ~test_deadline_timer()
+ ~test_system_timer()
{
m_timer.cancel();
m_timer_thread.join();
}
private:
- void expired(const boost::system::error_code & ec)
+ void expired(const websocketpp::lib::asio::error_code & ec)
{
- if (ec == boost::asio::error::operation_aborted)
+ if (ec == websocketpp::lib::asio::error::operation_aborted)
return;
BOOST_CHECK(!ec);
BOOST_FAIL("Test timed out");
}
- boost::asio::io_service m_io_service;
- boost::asio::deadline_timer m_timer;
+ websocketpp::lib::asio::io_context m_io_context;
+ websocketpp::lib::asio::system_timer m_timer;
websocketpp::lib::thread m_timer_thread;
};
@@ -426,7 +428,7 @@ BOOST_AUTO_TEST_CASE( pong_timeout ) {
websocketpp::lib::thread sthread(websocketpp::lib::bind(&run_server,&s,9005,false));
sleep(1); // give the server thread some time to start
- test_deadline_timer deadline(10);
+ test_system_timer deadline(10);
run_client(c, "http://localhost:9005",false);
@@ -447,7 +449,7 @@ BOOST_AUTO_TEST_CASE( client_open_handsh
sleep(1); // give the server thread some time to start
- test_deadline_timer deadline(10);
+ test_system_timer deadline(10);
run_client(c, "http://localhost:9005");
}
@@ -463,7 +465,7 @@ BOOST_AUTO_TEST_CASE( server_open_handsh
websocketpp::lib::thread sthread(websocketpp::lib::bind(&run_server,&s,9005,false));
- test_deadline_timer deadline(10);
+ test_system_timer deadline(10);
sleep(1); // give the server thread some time to start
@@ -488,7 +490,7 @@ BOOST_AUTO_TEST_CASE( client_self_initia
websocketpp::lib::thread sthread(websocketpp::lib::bind(&run_server,&s,9005,false));
- test_deadline_timer deadline(10);
+ test_system_timer deadline(10);
sleep(1); // give the server thread some time to start
@@ -521,7 +523,7 @@ BOOST_AUTO_TEST_CASE( server_self_initia
c.set_open_handler(bind(&delay,::_1,1));
websocketpp::lib::thread sthread(websocketpp::lib::bind(&run_server,&s,9005,false));
- test_deadline_timer deadline(10);
+ test_system_timer deadline(10);
sleep(1); // give the server thread some time to start
@@ -533,7 +535,7 @@ BOOST_AUTO_TEST_CASE( server_self_initia
BOOST_AUTO_TEST_CASE( client_runs_out_of_work ) {
client c;
- test_deadline_timer deadline(3);
+ test_system_timer deadline(3);
websocketpp::lib::error_code ec;
c.init_asio(ec);
@@ -541,7 +543,7 @@ BOOST_AUTO_TEST_CASE( client_runs_out_of
c.run();
- // This test checks that an io_service with no work ends immediately.
+ // This test checks that an io_context with no work ends immediately.
BOOST_CHECK(true);
}
@@ -599,7 +601,7 @@ BOOST_AUTO_TEST_CASE( stop_listening ) {
c.set_open_handler(bind(&close<client>,&c,::_1));
websocketpp::lib::thread sthread(websocketpp::lib::bind(&run_server,&s,9005,false));
- test_deadline_timer deadline(5);
+ test_system_timer deadline(5);
sleep(1); // give the server thread some time to start
Index: websocketpp/tutorials/utility_server/step1.cpp
===================================================================
--- websocketpp.orig/tutorials/utility_server/step1.cpp
+++ websocketpp/tutorials/utility_server/step1.cpp
@@ -57,7 +57,7 @@ public:
// Queues a connection accept operation
m_endpoint.start_accept();
- // Start the Asio io_service run loop
+ // Start the Asio io_context run loop
m_endpoint.run();
}
private:
Index: websocketpp/tutorials/utility_server/step2.cpp
===================================================================
--- websocketpp.orig/tutorials/utility_server/step2.cpp
+++ websocketpp/tutorials/utility_server/step2.cpp
@@ -68,7 +68,7 @@ public:
// Queues a connection accept operation
m_endpoint.start_accept();
- // Start the Asio io_service run loop
+ // Start the Asio io_context run loop
m_endpoint.run();
}
private:
Index: websocketpp/tutorials/utility_server/utility_server.md
===================================================================
--- websocketpp.orig/tutorials/utility_server/utility_server.md
+++ websocketpp/tutorials/utility_server/utility_server.md
@@ -56,7 +56,7 @@ m_endpoint.set_access_channels(websocket
Next, we initialize the transport system underlying the endpoint. This method is specific to the Asio transport not WebSocket++ core. It will not be necessary or present in endpoints that use a non-asio config.
-> **Note:** This example uses an internal Asio `io_service` that is managed by the endpoint itself. This is a simple arrangement suitable for programs where WebSocket++ is the only code using Asio. If you have an existing program that already manages an `io_service` object or want to build a new program where WebSocket++ handlers share an io_service with other handlers you can pass the `io_service` you want WebSocket++ to register its handlers on to the `init_asio()` method and it will use it instead of generating and managing its own. [TODO: FAQ link instead?]
+> **Note:** This example uses an internal Asio `io_context` that is managed by the endpoint itself. This is a simple arrangement suitable for programs where WebSocket++ is the only code using Asio. If you have an existing program that already manages an `io_context` object or want to build a new program where WebSocket++ handlers share an io_context with other handlers you can pass the `io_context` you want WebSocket++ to register its handlers on to the `init_asio()` method and it will use it instead of generating and managing its own. [TODO: FAQ link instead?]
~~~{.cpp}
m_endpoint.init_asio();
@@ -64,7 +64,7 @@ m_endpoint.init_asio();
#### `utility_server::run` method
-In addition to the constructor, we also add a run method that sets up the listening socket, begins accepting connections, starts the Asio io_service event loop.
+In addition to the constructor, we also add a run method that sets up the listening socket, begins accepting connections, starts the Asio io_context event loop.
~~~{.cpp}
// Listen on port 9002
@@ -73,7 +73,7 @@ m_endpoint.listen(9002);
// Queues a connection accept operation
m_endpoint.start_accept();
-// Start the Asio io_service run loop
+// Start the Asio io_context run loop
m_endpoint.run();
~~~
@@ -123,7 +123,7 @@ public:
// Queues a connection accept operation
m_endpoint.start_accept();
- // Start the Asio io_service run loop
+ // Start the Asio io_context run loop
m_endpoint.run();
}
private:
Index: websocketpp/websocketpp/roles/server_endpoint.hpp
===================================================================
--- websocketpp.orig/websocketpp/roles/server_endpoint.hpp
+++ websocketpp/websocketpp/roles/server_endpoint.hpp
@@ -137,8 +137,8 @@ public:
/// Starts the server's async connection acceptance loop (exception free)
/**
* Initiates the server connection acceptance loop. Must be called after
- * listen. This method will have no effect until the underlying io_service
- * starts running. It may be called after the io_service is already running.
+ * listen. This method will have no effect until the underlying io_context
+ * starts running. It may be called after the io_context is already running.
*
* Refer to documentation for the transport policy you are using for
* instructions on how to stop this acceptance loop.
Index: websocketpp/websocketpp/transport/asio/base.hpp
===================================================================
--- websocketpp.orig/websocketpp/transport/asio/base.hpp
+++ websocketpp/websocketpp/transport/asio/base.hpp
@@ -40,7 +40,7 @@ namespace websocketpp {
namespace transport {
/// Transport policy that uses asio
/**
- * This policy uses a single asio io_service to provide transport
+ * This policy uses a single asio io_context to provide transport
* services to a WebSocket++ endpoint.
*/
namespace asio {
Index: websocketpp/websocketpp/transport/asio/connection.hpp
===================================================================
--- websocketpp.orig/websocketpp/transport/asio/connection.hpp
+++ websocketpp/websocketpp/transport/asio/connection.hpp
@@ -85,10 +85,10 @@ public:
typedef typename config::response_type response_type;
typedef typename response_type::ptr response_ptr;
- /// Type of a pointer to the Asio io_service being used
- typedef lib::asio::io_service * io_service_ptr;
- /// Type of a pointer to the Asio io_service::strand being used
- typedef lib::shared_ptr<lib::asio::io_service::strand> strand_ptr;
+ /// Type of a pointer to the Asio io_context being used
+ typedef lib::asio::io_context * io_context_ptr;
+ /// Type of a pointer to the Asio io_context::strand being used
+ typedef lib::shared_ptr<lib::asio::io_context::strand> strand_ptr;
/// Type of a pointer to the Asio timer class
typedef lib::shared_ptr<lib::asio::steady_timer> timer_ptr;
@@ -97,7 +97,7 @@ public:
// to the public api.
friend class endpoint<config>;
- // generate and manage our own io_service
+ // generate and manage our own io_context
explicit connection(bool is_server, const lib::shared_ptr<alog_type> & alog, const lib::shared_ptr<elog_type> & elog)
: m_is_server(is_server)
, m_alog(alog)
@@ -319,12 +319,12 @@ public:
timer_ptr set_timer(long duration, timer_handler callback) {
timer_ptr new_timer(
new lib::asio::steady_timer(
- *m_io_service,
+ *m_io_context,
lib::asio::milliseconds(duration))
);
if (config::enable_multithreading) {
- new_timer->async_wait(m_strand->wrap(lib::bind(
+ new_timer->async_wait(lib::asio::bind_executor(*m_strand, lib::bind(
&type::handle_timer, get_shared(),
new_timer,
callback,
@@ -399,7 +399,7 @@ public:
/// Initialize transport for reading
/**
* init_asio is called once immediately after construction to initialize
- * Asio components to the io_service
+ * Asio components to the io_context
*
* The transport initialization sequence consists of the following steps:
* - Pre-init: the underlying socket is initialized to the point where
@@ -457,21 +457,21 @@ protected:
/// Finish constructing the transport
/**
* init_asio is called once immediately after construction to initialize
- * Asio components to the io_service.
+ * Asio components to the io_context.
*
- * @param io_service A pointer to the io_service to register with this
+ * @param io_context A pointer to the io_context to register with this
* connection
*
* @return Status code for the success or failure of the initialization
*/
- lib::error_code init_asio (io_service_ptr io_service) {
- m_io_service = io_service;
+ lib::error_code init_asio (io_context_ptr io_context) {
+ m_io_context = io_context;
if (config::enable_multithreading) {
- m_strand.reset(new lib::asio::io_service::strand(*io_service));
+ m_strand.reset(new lib::asio::io_context::strand(*io_context));
}
- lib::error_code ec = socket_con_type::init_asio(io_service, m_strand,
+ lib::error_code ec = socket_con_type::init_asio(io_context, m_strand,
m_is_server);
return ec;
@@ -579,7 +579,7 @@ protected:
lib::error_code const & ec)
{
if (ec == transport::error::operation_aborted ||
- (post_timer && lib::asio::is_neg(post_timer->expires_from_now())))
+ (post_timer && lib::asio::is_neg(post_timer->expiry() - timer_ptr::element_type::clock_type::now())))
{
m_alog->write(log::alevel::devel,"post_init cancelled");
return;
@@ -635,7 +635,7 @@ protected:
lib::asio::async_write(
socket_con_type::get_next_layer(),
m_bufs,
- m_strand->wrap(lib::bind(
+ lib::asio::bind_executor(*m_strand, lib::bind(
&type::handle_proxy_write, get_shared(),
callback,
lib::placeholders::_1
@@ -685,7 +685,7 @@ protected:
// Whatever aborted it will be issuing the callback so we are safe to
// return
if (ec == lib::asio::error::operation_aborted ||
- lib::asio::is_neg(m_proxy_data->timer->expires_from_now()))
+ lib::asio::is_neg(m_proxy_data->timer->expiry() - timer_ptr::element_type::clock_type::now()))
{
m_elog->write(log::elevel::devel,"write operation aborted");
return;
@@ -718,7 +718,7 @@ protected:
socket_con_type::get_next_layer(),
m_proxy_data->read_buf,
"\r\n\r\n",
- m_strand->wrap(lib::bind(
+ lib::asio::bind_executor(*m_strand, lib::bind(
&type::handle_proxy_read, get_shared(),
callback,
lib::placeholders::_1, lib::placeholders::_2
@@ -756,7 +756,7 @@ protected:
// Whatever aborted it will be issuing the callback so we are safe to
// return
if (ec == lib::asio::error::operation_aborted ||
- lib::asio::is_neg(m_proxy_data->timer->expires_from_now()))
+ lib::asio::is_neg(m_proxy_data->timer->expiry() - timer_ptr::element_type::clock_type::now()))
{
m_elog->write(log::elevel::devel,"read operation aborted");
return;
@@ -856,7 +856,7 @@ protected:
socket_con_type::get_socket(),
lib::asio::buffer(buf,len),
lib::asio::transfer_at_least(num_bytes),
- m_strand->wrap(make_custom_alloc_handler(
+ lib::asio::bind_executor(*m_strand, make_custom_alloc_handler(
m_read_handler_allocator,
lib::bind(
&type::handle_async_read, get_shared(),
@@ -925,7 +925,7 @@ protected:
lib::asio::async_write(
socket_con_type::get_socket(),
m_bufs,
- m_strand->wrap(make_custom_alloc_handler(
+ lib::asio::bind_executor(*m_strand, make_custom_alloc_handler(
m_write_handler_allocator,
lib::bind(
&type::handle_async_write, get_shared(),
@@ -965,7 +965,7 @@ protected:
lib::asio::async_write(
socket_con_type::get_socket(),
m_bufs,
- m_strand->wrap(make_custom_alloc_handler(
+ lib::asio::bind_executor(*m_strand, make_custom_alloc_handler(
m_write_handler_allocator,
lib::bind(
&type::handle_async_write, get_shared(),
@@ -1030,18 +1030,18 @@ protected:
*/
lib::error_code interrupt(interrupt_handler handler) {
if (config::enable_multithreading) {
- m_io_service->post(m_strand->wrap(handler));
+ lib::asio::post(m_io_context->get_executor(), lib::asio::bind_executor(*m_strand, handler));
} else {
- m_io_service->post(handler);
+ lib::asio::post(m_io_context->get_executor(), handler);
}
return lib::error_code();
}
lib::error_code dispatch(dispatch_handler handler) {
if (config::enable_multithreading) {
- m_io_service->post(m_strand->wrap(handler));
+ lib::asio::post(m_io_context->get_executor(), lib::asio::bind_executor(*m_strand, handler));
} else {
- m_io_service->post(handler);
+ lib::asio::post(m_io_context->get_executor(), handler);
}
return lib::error_code();
}
@@ -1113,7 +1113,7 @@ protected:
callback, lib::asio::error_code const & ec)
{
if (ec == lib::asio::error::operation_aborted ||
- lib::asio::is_neg(shutdown_timer->expires_from_now()))
+ lib::asio::is_neg(shutdown_timer->expiry() - timer_ptr::element_type::clock_type::now()))
{
m_alog->write(log::alevel::devel,"async_shutdown cancelled");
return;
@@ -1190,7 +1190,7 @@ private:
lib::shared_ptr<proxy_data> m_proxy_data;
// transport resources
- io_service_ptr m_io_service;
+ io_context_ptr m_io_context;
strand_ptr m_strand;
connection_hdl m_connection_hdl;
Index: websocketpp/websocketpp/transport/asio/endpoint.hpp
===================================================================
--- websocketpp.orig/websocketpp/transport/asio/endpoint.hpp
+++ websocketpp/websocketpp/transport/asio/endpoint.hpp
@@ -77,25 +77,25 @@ public:
/// associated with this endpoint transport component
typedef typename transport_con_type::ptr transport_con_ptr;
- /// Type of a pointer to the ASIO io_service being used
- typedef lib::asio::io_service * io_service_ptr;
+ /// Type of a pointer to the ASIO io_context being used
+ typedef lib::asio::io_context * io_context_ptr;
/// Type of a shared pointer to the acceptor being used
typedef lib::shared_ptr<lib::asio::ip::tcp::acceptor> acceptor_ptr;
/// Type of a shared pointer to the resolver being used
typedef lib::shared_ptr<lib::asio::ip::tcp::resolver> resolver_ptr;
/// Type of timer handle
typedef lib::shared_ptr<lib::asio::steady_timer> timer_ptr;
- /// Type of a shared pointer to an io_service work object
- typedef lib::shared_ptr<lib::asio::io_service::work> work_ptr;
+ /// Type of a shared pointer to an io_context work object
+ typedef lib::shared_ptr<lib::asio::executor_work_guard<lib::asio::io_context::executor_type>> work_guard_ptr;
/// Type of socket pre-bind handler
typedef lib::function<lib::error_code(acceptor_ptr)> tcp_pre_bind_handler;
- // generate and manage our own io_service
+ // generate and manage our own io_context
explicit endpoint()
- : m_io_service(NULL)
- , m_external_io_service(false)
- , m_listen_backlog(lib::asio::socket_base::max_connections)
+ : m_io_context(NULL)
+ , m_external_io_context(false)
+ , m_listen_backlog(lib::asio::socket_base::max_listen_connections)
, m_reuse_addr(false)
, m_state(UNINITIALIZED)
{
@@ -103,14 +103,14 @@ public:
}
~endpoint() {
- // clean up our io_service if we were initialized with an internal one.
+ // clean up our io_context if we were initialized with an internal one.
// Explicitly destroy local objects
m_acceptor.reset();
m_resolver.reset();
- m_work.reset();
- if (m_state != UNINITIALIZED && !m_external_io_service) {
- delete m_io_service;
+ m_work_guard.reset();
+ if (m_state != UNINITIALIZED && !m_external_io_context) {
+ delete m_io_context;
}
}
@@ -132,34 +132,34 @@ public:
: config::socket_type(std::move(src))
, m_tcp_pre_init_handler(src.m_tcp_pre_init_handler)
, m_tcp_post_init_handler(src.m_tcp_post_init_handler)
- , m_io_service(src.m_io_service)
- , m_external_io_service(src.m_external_io_service)
+ , m_io_context(src.m_io_context)
+ , m_external_io_context(src.m_external_io_context)
, m_acceptor(src.m_acceptor)
- , m_listen_backlog(lib::asio::socket_base::max_connections)
+ , m_listen_backlog(lib::asio::socket_base::max_listen_connections)
, m_reuse_addr(src.m_reuse_addr)
, m_elog(src.m_elog)
, m_alog(src.m_alog)
, m_state(src.m_state)
{
- src.m_io_service = NULL;
- src.m_external_io_service = false;
+ src.m_io_context = NULL;
+ src.m_external_io_context = false;
src.m_acceptor = NULL;
src.m_state = UNINITIALIZED;
}
/*endpoint & operator= (const endpoint && rhs) {
if (this != &rhs) {
- m_io_service = rhs.m_io_service;
- m_external_io_service = rhs.m_external_io_service;
+ m_io_context = rhs.m_io_context;
+ m_external_io_context = rhs.m_external_io_context;
m_acceptor = rhs.m_acceptor;
m_listen_backlog = rhs.m_listen_backlog;
m_reuse_addr = rhs.m_reuse_addr;
m_state = rhs.m_state;
- rhs.m_io_service = NULL;
- rhs.m_external_io_service = false;
+ rhs.m_io_context = NULL;
+ rhs.m_external_io_context = false;
rhs.m_acceptor = NULL;
- rhs.m_listen_backlog = lib::asio::socket_base::max_connections;
+ rhs.m_listen_backlog = lib::asio::socket_base::max_listen_connections;
rhs.m_state = UNINITIALIZED;
// TODO: this needs to be updated
@@ -173,16 +173,16 @@ public:
return socket_type::is_secure();
}
- /// initialize asio transport with external io_service (exception free)
+ /// initialize asio transport with external io_context (exception free)
/**
* Initialize the ASIO transport policy for this endpoint using the provided
- * io_service object. asio_init must be called exactly once on any endpoint
+ * io_context object. asio_init must be called exactly once on any endpoint
* that uses transport::asio before it can be used.
*
- * @param ptr A pointer to the io_service to use for asio events
+ * @param ptr A pointer to the io_context to use for asio events
* @param ec Set to indicate what error occurred, if any.
*/
- void init_asio(io_service_ptr ptr, lib::error_code & ec) {
+ void init_asio(io_context_ptr ptr, lib::error_code & ec) {
if (m_state != UNINITIALIZED) {
m_elog->write(log::elevel::library,
"asio::init_asio called from the wrong state");
@@ -193,36 +193,36 @@ public:
m_alog->write(log::alevel::devel,"asio::init_asio");
- m_io_service = ptr;
- m_external_io_service = true;
- m_acceptor.reset(new lib::asio::ip::tcp::acceptor(*m_io_service));
+ m_io_context = ptr;
+ m_external_io_context = true;
+ m_acceptor.reset(new lib::asio::ip::tcp::acceptor(*m_io_context));
m_state = READY;
ec = lib::error_code();
}
#ifndef _WEBSOCKETPP_NO_EXCEPTIONS_
- /// initialize asio transport with external io_service
+ /// initialize asio transport with external io_context
/**
* Initialize the ASIO transport policy for this endpoint using the provided
- * io_service object. asio_init must be called exactly once on any endpoint
+ * io_context object. asio_init must be called exactly once on any endpoint
* that uses transport::asio before it can be used.
*
- * @param ptr A pointer to the io_service to use for asio events
+ * @param ptr A pointer to the io_context to use for asio events
*/
- void init_asio(io_service_ptr ptr) {
+ void init_asio(io_context_ptr ptr) {
lib::error_code ec;
init_asio(ptr,ec);
if (ec) { throw exception(ec); }
}
#endif // _WEBSOCKETPP_NO_EXCEPTIONS_
- /// Initialize asio transport with internal io_service (exception free)
+ /// Initialize asio transport with internal io_context (exception free)
/**
* This method of initialization will allocate and use an internally managed
- * io_service.
+ * io_context.
*
- * @see init_asio(io_service_ptr ptr)
+ * @see init_asio(io_context_ptr ptr)
*
* @param ec Set to indicate what error occurred, if any.
*/
@@ -232,22 +232,22 @@ public:
// TODO: remove the use of auto_ptr when C++98/03 support is no longer
// necessary.
#ifdef _WEBSOCKETPP_CPP11_MEMORY_
- lib::unique_ptr<lib::asio::io_service> service(new lib::asio::io_service());
+ lib::unique_ptr<lib::asio::io_context> context(new lib::asio::io_context());
#else
- lib::auto_ptr<lib::asio::io_service> service(new lib::asio::io_service());
+ lib::auto_ptr<lib::asio::io_context> context(new lib::asio::io_context());
#endif
- init_asio(service.get(), ec);
- if( !ec ) service.release(); // Call was successful, transfer ownership
- m_external_io_service = false;
+ init_asio(context.get(), ec);
+ if( !ec ) context.release(); // Call was successful, transfer ownership
+ m_external_io_context = false;
}
#ifndef _WEBSOCKETPP_NO_EXCEPTIONS_
- /// Initialize asio transport with internal io_service
+ /// Initialize asio transport with internal io_context
/**
* This method of initialization will allocate and use an internally managed
- * io_service.
+ * io_context.
*
- * @see init_asio(io_service_ptr ptr)
+ * @see init_asio(io_context_ptr ptr)
*/
void init_asio() {
// Use a smart pointer until the call is successful and ownership has
@@ -255,14 +255,14 @@ public:
// TODO: remove the use of auto_ptr when C++98/03 support is no longer
// necessary.
#ifdef _WEBSOCKETPP_CPP11_MEMORY_
- lib::unique_ptr<lib::asio::io_service> service(new lib::asio::io_service());
+ lib::unique_ptr<lib::asio::io_context> context(new lib::asio::io_context());
#else
- lib::auto_ptr<lib::asio::io_service> service(new lib::asio::io_service());
+ lib::auto_ptr<lib::asio::io_context> context(new lib::asio::io_context());
#endif
- init_asio( service.get() );
+ init_asio( context.get() );
// If control got this far without an exception, then ownership has successfully been taken
- service.release();
- m_external_io_service = false;
+ context.release();
+ m_external_io_context = false;
}
#endif // _WEBSOCKETPP_NO_EXCEPTIONS_
@@ -334,7 +334,7 @@ public:
*
* New values affect future calls to listen only.
*
- * The default value is specified as *::asio::socket_base::max_connections
+ * The default value is specified as *::asio::socket_base::max_listen_connections
* which uses the operating system defined maximum queue length. Your OS
* may restrict or silently lower this value. A value of zero may cause
* all connections to be rejected.
@@ -368,19 +368,19 @@ public:
m_reuse_addr = value;
}
- /// Retrieve a reference to the endpoint's io_service
+ /// Retrieve a reference to the endpoint's io_context
/**
- * The io_service may be an internal or external one. This may be used to
- * call methods of the io_service that are not explicitly wrapped by the
+ * The io_context may be an internal or external one. This may be used to
+ * call methods of the io_context that are not explicitly wrapped by the
* endpoint.
*
* This method is only valid after the endpoint has been initialized with
* `init_asio`. No error will be returned if it isn't.
*
- * @return A reference to the endpoint's io_service
+ * @return A reference to the endpoint's io_context
*/
- lib::asio::io_service & get_io_service() {
- return *m_io_service;
+ lib::asio::io_context & get_io_context() {
+ return *m_io_context;
}
/// Get local TCP endpoint
@@ -495,13 +495,12 @@ public:
/**
* Bind the internal acceptor using the given host and service. More details
* about what host and service can be are available in the Asio
- * documentation for ip::basic_resolver_query::basic_resolver_query's
- * constructors.
+ * documentation for the ip::basic_resolver::resolve function.
*
* The endpoint must have been initialized by calling init_asio before
* listening.
*
- * Once listening the underlying io_service will be kept open indefinitely.
+ * Once listening the underlying io_context will be kept open indefinitely.
* Calling endpoint::stop_listening will stop the endpoint from accepting
* new connections. See the documentation for stop listening for more details
* about shutting down Asio Transport based endpoints.
@@ -518,17 +517,15 @@ public:
lib::error_code & ec)
{
using lib::asio::ip::tcp;
- tcp::resolver r(*m_io_service);
- tcp::resolver::query query(host, service);
- tcp::resolver::iterator endpoint_iterator = r.resolve(query);
- tcp::resolver::iterator end;
- if (endpoint_iterator == end) {
+ tcp::resolver r(*m_io_context);
+ tcp::resolver::results_type results = r.resolve(host, service);
+ if (results.empty()) {
m_elog->write(log::elevel::library,
"asio::listen could not resolve the supplied host or service");
ec = make_error_code(error::invalid_host_service);
return;
}
- listen(*endpoint_iterator,ec);
+ listen(*(results.begin()),ec);
}
/// Stop listening (exception free)
@@ -615,13 +612,12 @@ public:
/**
* Bind the internal acceptor using the given host and service. More
* details about what host and service can be are available in the Asio
- * documentation for ip::basic_resolver_query::basic_resolver_query's
- * constructors.
+ * documentation for the ip::basic_resolver::resolve function.
*
* The endpoint must have been initialized by calling init_asio before
* listening.
*
- * Once listening the underlying io_service will be kept open indefinitely.
+ * Once listening the underlying io_context will be kept open indefinitely.
* Calling endpoint::stop_listening will stop the endpoint from accepting
* new connections. See the documentation for stop listening for more
* details about shutting down Asio Transport based endpoints.
@@ -663,42 +659,42 @@ public:
return (m_state == LISTENING);
}
- /// wraps the run method of the internal io_service object
+ /// wraps the run method of the internal io_context object
std::size_t run() {
- return m_io_service->run();
+ return m_io_context->run();
}
- /// wraps the run_one method of the internal io_service object
+ /// wraps the run_one method of the internal io_context object
/**
* @since 0.3.0-alpha4
*/
std::size_t run_one() {
- return m_io_service->run_one();
+ return m_io_context->run_one();
}
- /// wraps the stop method of the internal io_service object
+ /// wraps the stop method of the internal io_context object
void stop() {
- m_io_service->stop();
+ m_io_context->stop();
}
- /// wraps the poll method of the internal io_service object
+ /// wraps the poll method of the internal io_context object
std::size_t poll() {
- return m_io_service->poll();
+ return m_io_context->poll();
}
- /// wraps the poll_one method of the internal io_service object
+ /// wraps the poll_one method of the internal io_context object
std::size_t poll_one() {
- return m_io_service->poll_one();
+ return m_io_context->poll_one();
}
- /// wraps the reset method of the internal io_service object
+ /// wraps the restart method of the internal io_context object
void reset() {
- m_io_service->reset();
+ m_io_context->restart();
}
- /// wraps the stopped method of the internal io_service object
+ /// wraps the stopped method of the internal io_context object
bool stopped() const {
- return m_io_service->stopped();
+ return m_io_context->stopped();
}
/// Marks the endpoint as perpetual, stopping it from exiting when empty
@@ -714,7 +710,7 @@ public:
* @since 0.3.0
*/
void start_perpetual() {
- m_work.reset(new lib::asio::io_service::work(*m_io_service));
+ m_work_guard.reset(new lib::asio::executor_work_guard<lib::asio::io_context::executor_type>(m_io_context->get_executor()));
}
/// Clears the endpoint's perpetual flag, allowing it to exit when empty
@@ -726,7 +722,7 @@ public:
* @since 0.3.0
*/
void stop_perpetual() {
- m_work.reset();
+ m_work_guard.reset();
}
/// Call back a function after a period of time.
@@ -743,7 +739,7 @@ public:
*/
timer_ptr set_timer(long duration, timer_handler callback) {
timer_ptr new_timer = lib::make_shared<lib::asio::steady_timer>(
- *m_io_service,
+ *m_io_context,
lib::asio::milliseconds(duration)
);
@@ -806,7 +802,7 @@ public:
if (config::enable_multithreading) {
m_acceptor->async_accept(
tcon->get_raw_socket(),
- tcon->get_strand()->wrap(lib::bind(
+ lib::asio::bind_executor(*tcon->get_strand(), lib::bind(
&type::handle_accept,
this,
callback,
@@ -880,7 +876,7 @@ protected:
// Create a resolver
if (!m_resolver) {
- m_resolver.reset(new lib::asio::ip::tcp::resolver(*m_io_service));
+ m_resolver.reset(new lib::asio::ip::tcp::resolver(*m_io_context));
}
tcon->set_uri(u);
@@ -912,8 +908,6 @@ protected:
port = pu->get_port_str();
}
- tcp::resolver::query query(host,port);
-
if (m_alog->static_test(log::alevel::devel)) {
m_alog->write(log::alevel::devel,
"starting async DNS resolve for "+host+":"+port);
@@ -934,8 +928,9 @@ protected:
if (config::enable_multithreading) {
m_resolver->async_resolve(
- query,
- tcon->get_strand()->wrap(lib::bind(
+ host,
+ port,
+ lib::asio::bind_executor(*tcon->get_strand(), lib::bind(
&type::handle_resolve,
this,
tcon,
@@ -947,7 +942,8 @@ protected:
);
} else {
m_resolver->async_resolve(
- query,
+ host,
+ port,
lib::bind(
&type::handle_resolve,
this,
@@ -995,10 +991,10 @@ protected:
void handle_resolve(transport_con_ptr tcon, timer_ptr dns_timer,
connect_handler callback, lib::asio::error_code const & ec,
- lib::asio::ip::tcp::resolver::iterator iterator)
+ lib::asio::ip::tcp::resolver::results_type results)
{
if (ec == lib::asio::error::operation_aborted ||
- lib::asio::is_neg(dns_timer->expires_from_now()))
+ lib::asio::is_neg(dns_timer->expiry() - timer_ptr::element_type::clock_type::now()))
{
m_alog->write(log::alevel::devel,"async_resolve cancelled");
return;
@@ -1016,8 +1012,8 @@ protected:
std::stringstream s;
s << "Async DNS resolve successful. Results: ";
- lib::asio::ip::tcp::resolver::iterator it, end;
- for (it = iterator; it != end; ++it) {
+ lib::asio::ip::tcp::resolver::results_type::iterator it;
+ for (it = results.begin(); it != results.end(); ++it) {
s << (*it).endpoint() << " ";
}
@@ -1043,8 +1039,8 @@ protected:
if (config::enable_multithreading) {
lib::asio::async_connect(
tcon->get_raw_socket(),
- iterator,
- tcon->get_strand()->wrap(lib::bind(
+ results,
+ lib::asio::bind_executor(*tcon->get_strand(), lib::bind(
&type::handle_connect,
this,
tcon,
@@ -1056,7 +1052,7 @@ protected:
} else {
lib::asio::async_connect(
tcon->get_raw_socket(),
- iterator,
+ results,
lib::bind(
&type::handle_connect,
this,
@@ -1106,7 +1102,7 @@ protected:
connect_handler callback, lib::asio::error_code const & ec)
{
if (ec == lib::asio::error::operation_aborted ||
- lib::asio::is_neg(con_timer->expires_from_now()))
+ lib::asio::is_neg(con_timer->expiry() - timer_ptr::element_type::clock_type::now()))
{
m_alog->write(log::alevel::devel,"async_connect cancelled");
return;
@@ -1148,7 +1144,7 @@ protected:
lib::error_code ec;
- ec = tcon->init_asio(m_io_service);
+ ec = tcon->init_asio(m_io_context);
if (ec) {return ec;}
tcon->set_tcp_pre_init_handler(m_tcp_pre_init_handler);
@@ -1187,11 +1183,11 @@ private:
tcp_init_handler m_tcp_post_init_handler;
// Network Resources
- io_service_ptr m_io_service;
- bool m_external_io_service;
+ io_context_ptr m_io_context;
+ bool m_external_io_context;
acceptor_ptr m_acceptor;
resolver_ptr m_resolver;
- work_ptr m_work;
+ work_guard_ptr m_work_guard;
// Network constants
int m_listen_backlog;
Index: websocketpp/websocketpp/transport/asio/security/none.hpp
===================================================================
--- websocketpp.orig/websocketpp/transport/asio/security/none.hpp
+++ websocketpp/websocketpp/transport/asio/security/none.hpp
@@ -62,10 +62,10 @@ public:
/// Type of a shared pointer to this connection socket component
typedef lib::shared_ptr<type> ptr;
- /// Type of a pointer to the Asio io_service being used
- typedef lib::asio::io_service* io_service_ptr;
- /// Type of a pointer to the Asio io_service strand being used
- typedef lib::shared_ptr<lib::asio::io_service::strand> strand_ptr;
+ /// Type of a pointer to the Asio io_context being used
+ typedef lib::asio::io_context* io_context_ptr;
+ /// Type of a pointer to the Asio io_context strand being used
+ typedef lib::shared_ptr<lib::asio::io_context::strand> strand_ptr;
/// Type of the ASIO socket being used
typedef lib::asio::ip::tcp::socket socket_type;
/// Type of a shared pointer to the socket being used.
@@ -156,20 +156,20 @@ protected:
/// Perform one time initializations
/**
* init_asio is called once immediately after construction to initialize
- * Asio components to the io_service. At this stage the connection is
+ * Asio components to the io_context. At this stage the connection is
* speculative, the server may not have actually received a new connection.
*
- * @param service A pointer to the endpoint's io_service
+ * @param context A pointer to the endpoint's io_context
* @param strand A shared pointer to the connection's asio strand
* @param is_server Whether or not the endpoint is a server or not.
*/
- lib::error_code init_asio (io_service_ptr service, strand_ptr, bool)
+ lib::error_code init_asio (io_context_ptr context, strand_ptr, bool)
{
if (m_state != UNINITIALIZED) {
return socket::make_error_code(socket::error::invalid_state);
}
- m_socket.reset(new lib::asio::ip::tcp::socket(*service));
+ m_socket.reset(new lib::asio::ip::tcp::socket(*context));
m_state = READY;
Index: websocketpp/websocketpp/transport/asio/security/tls.hpp
===================================================================
--- websocketpp.orig/websocketpp/transport/asio/security/tls.hpp
+++ websocketpp/websocketpp/transport/asio/security/tls.hpp
@@ -71,10 +71,10 @@ public:
typedef lib::asio::ssl::stream<lib::asio::ip::tcp::socket> socket_type;
/// Type of a shared pointer to the ASIO socket being used
typedef lib::shared_ptr<socket_type> socket_ptr;
- /// Type of a pointer to the ASIO io_service being used
- typedef lib::asio::io_service * io_service_ptr;
- /// Type of a pointer to the ASIO io_service strand being used
- typedef lib::shared_ptr<lib::asio::io_service::strand> strand_ptr;
+ /// Type of a pointer to the ASIO io_context being used
+ typedef lib::asio::io_context * io_context_ptr;
+ /// Type of a pointer to the ASIO io_context strand being used
+ typedef lib::shared_ptr<lib::asio::io_context::strand> strand_ptr;
/// Type of a shared pointer to the ASIO TLS context being used
typedef lib::shared_ptr<lib::asio::ssl::context> context_ptr;
@@ -176,13 +176,13 @@ protected:
/// Perform one time initializations
/**
* init_asio is called once immediately after construction to initialize
- * Asio components to the io_service
+ * Asio components to the io_context
*
- * @param service A pointer to the endpoint's io_service
+ * @param context A pointer to the endpoint's io_context
* @param strand A pointer to the connection's strand
* @param is_server Whether or not the endpoint is a server or not.
*/
- lib::error_code init_asio (io_service_ptr service, strand_ptr strand,
+ lib::error_code init_asio (io_context_ptr context, strand_ptr strand,
bool is_server)
{
if (!m_tls_init_handler) {
@@ -193,9 +193,9 @@ protected:
if (!m_context) {
return socket::make_error_code(socket::error::invalid_tls_context);
}
- m_socket.reset(new socket_type(*service, *m_context));
+ m_socket.reset(new socket_type(*context, *m_context));
- m_io_service = service;
+ m_io_context = context;
m_strand = strand;
m_is_server = is_server;
@@ -240,6 +240,7 @@ protected:
// run the hostname through make_address to check if it is a valid IP literal
lib::asio::ip::address addr = lib::asio::ip::make_address(host, ec_addr);
+ (void)addr;
// If the parsing as an IP literal fails, proceed to register the hostname
// with the TLS handshake via SNI.
@@ -276,7 +277,7 @@ protected:
if (m_strand) {
m_socket->async_handshake(
get_handshake_type(),
- m_strand->wrap(lib::bind(
+ lib::asio::bind_executor(*m_strand, lib::bind(
&type::handle_init, get_shared(),
callback,
lib::placeholders::_1
@@ -336,7 +337,7 @@ protected:
void async_shutdown(socket::shutdown_handler callback) {
if (m_strand) {
- m_socket->async_shutdown(m_strand->wrap(callback));
+ m_socket->async_shutdown(lib::asio::bind_executor(*m_strand, callback));
} else {
m_socket->async_shutdown(callback);
}
@@ -391,7 +392,7 @@ private:
}
}
- io_service_ptr m_io_service;
+ io_context_ptr m_io_context;
strand_ptr m_strand;
context_ptr m_context;
socket_ptr m_socket;
Index: websocketpp/websocketpp/transport/debug/endpoint.hpp
===================================================================
--- websocketpp.orig/websocketpp/transport/debug/endpoint.hpp
+++ websocketpp/websocketpp/transport/debug/endpoint.hpp
@@ -60,7 +60,7 @@ public:
/// associated connection transport component
typedef typename transport_con_type::ptr transport_con_ptr;
- // generate and manage our own io_service
+ // generate and manage our own io_context
explicit endpoint()
{
//std::cout << "transport::iostream::endpoint constructor" << std::endl;
Index: websocketpp/websocketpp/transport/iostream/endpoint.hpp
===================================================================
--- websocketpp.orig/websocketpp/transport/iostream/endpoint.hpp
+++ websocketpp/websocketpp/transport/iostream/endpoint.hpp
@@ -64,7 +64,7 @@ public:
/// associated connection transport component
typedef typename transport_con_type::ptr transport_con_ptr;
- // generate and manage our own io_service
+ // generate and manage our own io_context
explicit endpoint() : m_output_stream(NULL), m_is_secure(false)
{
//std::cout << "transport::iostream::endpoint constructor" << std::endl;
Index: websocketpp/websocketpp/transport/stub/endpoint.hpp
===================================================================
--- websocketpp.orig/websocketpp/transport/stub/endpoint.hpp
+++ websocketpp/websocketpp/transport/stub/endpoint.hpp
@@ -60,7 +60,7 @@ public:
/// associated connection transport component
typedef typename transport_con_type::ptr transport_con_ptr;
- // generate and manage our own io_service
+ // generate and manage our own io_context
explicit endpoint()
{
//std::cout << "transport::iostream::endpoint constructor" << std::endl;
Index: websocketpp/CMakeLists.txt
===================================================================
--- websocketpp.orig/CMakeLists.txt
+++ websocketpp/CMakeLists.txt
@@ -2,7 +2,7 @@
############ Setup project and cmake
# Minimum cmake requirement. We should require a quite recent
# cmake for the dependency find macros etc. to be up to date.
-cmake_minimum_required (VERSION 2.8.8)
+cmake_minimum_required (VERSION 3.10)
############ Paths
@@ -77,6 +77,7 @@ include (CMakeHelpers)
option (ENABLE_CPP11 "Build websocketpp with CPP11 features enabled." TRUE)
option (BUILD_EXAMPLES "Build websocketpp examples." FALSE)
option (BUILD_TESTS "Build websocketpp tests." FALSE)
+option (USE_ASIO_STANDALONE "Build websocketpp examples and tests using the standalone ASIO library." FALSE)
if (BUILD_TESTS OR BUILD_EXAMPLES)
@@ -221,9 +222,8 @@ if (BUILD_TESTS OR BUILD_EXAMPLES)
set (Boost_FIND_QUIETLY TRUE)
set (Boost_DEBUG FALSE)
set (Boost_USE_MULTITHREADED TRUE)
- set (Boost_ADDITIONAL_VERSIONS "1.39.0" "1.40.0" "1.41.0" "1.42.0" "1.43.0" "1.44.0" "1.46.1") # todo: someone who knows better spesify these!
- find_package (Boost 1.39.0 COMPONENTS ${WEBSOCKETPP_BOOST_LIBS})
+ find_package (Boost 1.66.0 NO_MODULE COMPONENTS ${WEBSOCKETPP_BOOST_LIBS})
if (Boost_FOUND)
# Boost is a project wide global dependency.
@@ -254,6 +254,10 @@ endif()
############ Add projects
+if (USE_ASIO_STANDALONE)
+ add_definitions("-DASIO_STANDALONE -DASIO_HAS_BOOST_DATE_TIME")
+endif ()
+
# Add main library
add_subdirectory (websocketpp)
Index: websocketpp/test/http/parser_perf.cpp
===================================================================
--- websocketpp.orig/test/http/parser_perf.cpp
+++ websocketpp/test/http/parser_perf.cpp
@@ -31,11 +31,11 @@
class scoped_timer {
public:
- scoped_timer(std::string i) : m_id(i),m_start(std::chrono::steady_clock::now()) {
+ scoped_timer(std::string i) : m_id(i),m_start(timer_ptr::element_type::clock_type::now()) {
std::cout << "Clock " << i << ": ";
}
~scoped_timer() {
- std::chrono::nanoseconds time_taken = std::chrono::steady_clock::now()-m_start;
+ std::chrono::nanoseconds time_taken = timer_ptr::element_type::clock_type::now()-m_start;
//nanoseconds_per_test
Index: websocketpp/websocketpp/common/asio.hpp
===================================================================
--- websocketpp.orig/websocketpp/common/asio.hpp
+++ websocketpp/websocketpp/common/asio.hpp
@@ -51,7 +51,7 @@
#include <asio.hpp>
#include <asio/steady_timer.hpp>
- #include <websocketpp/common/chrono.hpp>
+ #include <websocketpp/common/chrono.hpp>
#else
#include <boost/version.hpp>
Index: websocketpp/websocketpp/common/random.hpp
===================================================================
--- websocketpp.orig/websocketpp/common/random.hpp
+++ websocketpp/websocketpp/common/random.hpp
@@ -53,16 +53,8 @@
#ifdef _WEBSOCKETPP_CPP11_RANDOM_DEVICE_
#include <random>
#else
- #include <boost/version.hpp>
-
- #if (BOOST_VERSION/100000) == 1 && ((BOOST_VERSION/100)%1000) > 46
- #include <boost/random/uniform_int_distribution.hpp>
- #include <boost/random/random_device.hpp>
- #elif (BOOST_VERSION/100000) == 1 && ((BOOST_VERSION/100)%1000) >= 43
- #include <boost/nondet_random.hpp>
- #else
- // TODO: static_assert(false, "Could not find a suitable random_device")
- #endif
+ #include <boost/random/uniform_int_distribution.hpp>
+ #include <boost/random/random_device.hpp>
#endif
namespace websocketpp {
|