/usr/share/doc/liblwt-ocaml-dev/api/Lwt_unix.html is in liblwt-ocaml-doc 2.4.3-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="previous" href="Lwt_timeout.html">
<link rel="next" href="Lwt_sys.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of class attributes" rel=Appendix href="index_attributes.html">
<link title="Index of class methods" rel=Appendix href="index_methods.html">
<link title="Index of classes" rel=Appendix href="index_classes.html">
<link title="Index of class types" rel=Appendix href="index_class_types.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Lwt_condition" rel="Chapter" href="Lwt_condition.html">
<link title="Lwt_list" rel="Chapter" href="Lwt_list.html">
<link title="Lwt" rel="Chapter" href="Lwt.html">
<link title="Lwt_mutex" rel="Chapter" href="Lwt_mutex.html">
<link title="Lwt_mvar" rel="Chapter" href="Lwt_mvar.html">
<link title="Lwt_pool" rel="Chapter" href="Lwt_pool.html">
<link title="Lwt_sequence" rel="Chapter" href="Lwt_sequence.html">
<link title="Lwt_stream" rel="Chapter" href="Lwt_stream.html">
<link title="Lwt_switch" rel="Chapter" href="Lwt_switch.html">
<link title="Lwt_util" rel="Chapter" href="Lwt_util.html">
<link title="Lwt_pqueue" rel="Chapter" href="Lwt_pqueue.html">
<link title="Lwt_lib" rel="Chapter" href="Lwt_lib.html">
<link title="Lwt_glib" rel="Chapter" href="Lwt_glib.html">
<link title="Lwt_preemptive" rel="Chapter" href="Lwt_preemptive.html">
<link title="Lwt_event" rel="Chapter" href="Lwt_event.html">
<link title="Lwt_signal" rel="Chapter" href="Lwt_signal.html">
<link title="Lwt_react" rel="Chapter" href="Lwt_react.html">
<link title="Lwt_ssl" rel="Chapter" href="Lwt_ssl.html">
<link title="Lwt_text" rel="Chapter" href="Lwt_text.html">
<link title="Lwt_term" rel="Chapter" href="Lwt_term.html">
<link title="Lwt_read_line" rel="Chapter" href="Lwt_read_line.html">
<link title="Lwt_top" rel="Chapter" href="Lwt_top.html">
<link title="Lwt_chan" rel="Chapter" href="Lwt_chan.html">
<link title="Lwt_daemon" rel="Chapter" href="Lwt_daemon.html">
<link title="Lwt_gc" rel="Chapter" href="Lwt_gc.html">
<link title="Lwt_io" rel="Chapter" href="Lwt_io.html">
<link title="Lwt_log" rel="Chapter" href="Lwt_log.html">
<link title="Lwt_main" rel="Chapter" href="Lwt_main.html">
<link title="Lwt_process" rel="Chapter" href="Lwt_process.html">
<link title="Lwt_throttle" rel="Chapter" href="Lwt_throttle.html">
<link title="Lwt_timeout" rel="Chapter" href="Lwt_timeout.html">
<link title="Lwt_unix" rel="Chapter" href="Lwt_unix.html">
<link title="Lwt_sys" rel="Chapter" href="Lwt_sys.html">
<link title="Lwt_engine" rel="Chapter" href="Lwt_engine.html">
<link title="Lwt_bytes" rel="Chapter" href="Lwt_bytes.html">
<link title="Pa_lwt" rel="Chapter" href="Pa_lwt.html">
<link title="Pa_lwt_log" rel="Chapter" href="Pa_lwt_log.html"><link title="Configuration" rel="Section" href="#6_Configuration">
<link title="Sleeping" rel="Section" href="#6_Sleeping">
<link title="Operation on file-descriptors" rel="Section" href="#6_Operationonfiledescriptors">
<link title="Process handling" rel="Section" href="#6_Processhandling">
<link title="Basic file input/output" rel="Section" href="#6_Basicfileinputoutput">
<link title="Seeking and truncating" rel="Section" href="#6_Seekingandtruncating">
<link title="Syncing" rel="Section" href="#6_Syncing">
<link title="File status" rel="Section" href="#6_Filestatus">
<link title="File operations on large files" rel="Section" href="#6_Fileoperationsonlargefiles">
<link title="Operations on file names" rel="Section" href="#6_Operationsonfilenames">
<link title="File permissions and ownership" rel="Section" href="#6_Filepermissionsandownership">
<link title="Operations on file descriptors" rel="Section" href="#6_Operationsonfiledescriptors">
<link title="Directories" rel="Section" href="#6_Directories">
<link title="Pipes and redirections" rel="Section" href="#6_Pipesandredirections">
<link title="Symbolic links" rel="Section" href="#6_Symboliclinks">
<link title="Locking" rel="Section" href="#6_Locking">
<link title="User id, group id" rel="Section" href="#6_Useridgroupid">
<link title="Signals" rel="Section" href="#6_Signals">
<link title="Sockets" rel="Section" href="#6_Sockets">
<link title="Host and protocol databases" rel="Section" href="#6_Hostandprotocoldatabases">
<link title="Terminal interface" rel="Section" href="#6_Terminalinterface">
<link title="Low-level interaction" rel="Section" href="#6_Lowlevelinteraction">
<link title="Notifications" rel="Section" href="#6_Notifications">
<link title="System threads pool" rel="Section" href="#6_Systemthreadspool">
<link title="CPUs" rel="Section" href="#6_CPUs">
<link title="Socket options" rel="Subsection" href="#8_Socketoptions">
<title>Lwt_unix</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Lwt_timeout.html" title="Lwt_timeout">Previous</a>
<a class="up" href="index.html" title="Index">Up</a>
<a class="post" href="Lwt_sys.html" title="Lwt_sys">Next</a>
</div>
<h1>Module <a href="type_Lwt_unix.html">Lwt_unix</a></h1>
<pre><span class="keyword">module</span> Lwt_unix: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_unix.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
Cooperative system calls<br>
</div>
<hr width="100%">
<br>
This modules redefine system calls, as in the <code class="code"><span class="constructor">Unix</span></code> module of the
standard library, but mapped into cooperative ones, which will not
block the program, letting other threads run.
<p>
The semantic of all operations is the following: if the action
(for example reading from a <b>file descriptor</b>) can be performed
immediatly, it is done and returns immediatly, otherwise it
returns a sleeping threads which is waked up when the operation
completes.
<p>
Most operations on sockets and pipes (on Windows it is only
sockets) are <b>cancelable</b>, this means that you can cancel them
with <a href="Lwt.html#VALcancel"><code class="code"><span class="constructor">Lwt</span>.cancel</code></a>. For example if you want to read something from
a <b>file descriptor</b> with a timeout, you can cancel the action
after the timeout and the reading will not be performed if not
already done.
<p>
More precisely, assuming that you have two sockets <code class="code">sock1</code> and
<code class="code">sock2</code> and you want to read something from <code class="code">sock1</code> or exclusively
from <code class="code">sock2</code>, and fail with an exception if a timeout of 1 second
expires, without reading anything from <code class="code">sock1</code> and <code class="code">sock2</code>, even
if they become readable in the future.
<p>
Then you can do:
<p>
<pre class="codepre"><code class="code"> <span class="constructor">Lwt</span>.pick [<span class="constructor">Lwt_unix</span>.timeout 1.0; read sock1 buf1 ofs1 len1; read sock2 buf2 ofs2 len2]<br>
</code></pre>
<p>
In this case it is guaranteed that exactly one of the three
operations will completes, and other will just be cancelled.<br>
<pre><span id="VALhandle_unix_error"><span class="keyword">val</span> handle_unix_error</span> : <code class="type">('a -> 'b <a href="Lwt.html#TYPEt">Lwt.t</a>) -> 'a -> 'b <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Same as <code class="code"><span class="constructor">Unix</span>.handle_unix_error</code> but catches lwt-level
exceptions<br>
</div>
<br>
<h6 id="6_Configuration">Configuration</h6><br>
<pre><code><span id="TYPEasync_method"><span class="keyword">type</span> <code class="type"></code>async_method</span> = </code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTasync_method.Async_none"><span class="constructor">Async_none</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >System calls are made synchronously, and may block the
entire program.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTasync_method.Async_detach"><span class="constructor">Async_detach</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >System calls are made in another system thread, thus without
blocking other Lwt threads. The drawback is that it may
degrade performances in some cases.
<p>
This is the default.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTasync_method.Async_switch"><span class="constructor">Async_switch</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >System calls are made in the main thread, and if one blocks
the execution continue in another system thread. This method
is the most efficint, also you will get better performances
if you force all threads to run on the same cpu. On linux
this can be done by using the command <code class="code">taskset</code>.
<p>
Note that this method is still experimental.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
<div class="info ">
For system calls that cannot be made asynchronously, Lwt uses one
of the following method:<br>
</div>
<pre><span id="VALdefault_async_method"><span class="keyword">val</span> default_async_method</span> : <code class="type">unit -> <a href="Lwt_unix.html#TYPEasync_method">async_method</a></code></pre><div class="info ">
Returns the default async method.
<p>
This can be initialized using the environment variable
<code class="code"><span class="string">"LWT_ASYNC_METHOD"</span></code> with possible values <code class="code"><span class="string">"none"</span></code>,
<code class="code"><span class="string">"detach"</span></code> and <code class="code"><span class="string">"switch"</span></code>.<br>
</div>
<pre><span id="VALset_default_async_method"><span class="keyword">val</span> set_default_async_method</span> : <code class="type"><a href="Lwt_unix.html#TYPEasync_method">async_method</a> -> unit</code></pre><div class="info ">
Sets the default async method.<br>
</div>
<pre><span id="VALasync_method"><span class="keyword">val</span> async_method</span> : <code class="type">unit -> <a href="Lwt_unix.html#TYPEasync_method">async_method</a></code></pre><div class="info ">
<code class="code">async_method ()</code> returns the async method used in the current
thread.<br>
</div>
<pre><span id="VALasync_method_key"><span class="keyword">val</span> async_method_key</span> : <code class="type"><a href="Lwt_unix.html#TYPEasync_method">async_method</a> <a href="Lwt.html#TYPEkey">Lwt.key</a></code></pre><div class="info ">
The key for storing the local async method.<br>
</div>
<pre><span id="VALwith_async_none"><span class="keyword">val</span> with_async_none</span> : <code class="type">(unit -> 'a) -> 'a</code></pre><div class="info ">
<code class="code">with_async_none f</code> is a shorthand for:
<p>
<pre class="codepre"><code class="code"> <span class="constructor">Lwt</span>.with_value async_method_key (<span class="constructor">Some</span> <span class="constructor">Async_none</span>) f<br>
</code></pre><br>
</div>
<pre><span id="VALwith_async_detach"><span class="keyword">val</span> with_async_detach</span> : <code class="type">(unit -> 'a) -> 'a</code></pre><div class="info ">
<code class="code">with_async_none f</code> is a shorthand for:
<p>
<pre class="codepre"><code class="code"> <span class="constructor">Lwt</span>.with_value async_method_key (<span class="constructor">Some</span> <span class="constructor">Async_detach</span>) f<br>
</code></pre><br>
</div>
<pre><span id="VALwith_async_switch"><span class="keyword">val</span> with_async_switch</span> : <code class="type">(unit -> 'a) -> 'a</code></pre><div class="info ">
<code class="code">with_async_none f</code> is a shorthand for:
<p>
<pre class="codepre"><code class="code"> <span class="constructor">Lwt</span>.with_value async_method_key (<span class="constructor">Some</span> <span class="constructor">Async_switch</span>) f<br>
</code></pre><br>
</div>
<br>
<h6 id="6_Sleeping">Sleeping</h6><br>
<pre><span id="VALsleep"><span class="keyword">val</span> sleep</span> : <code class="type">float -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">sleep d</code> is a threads which remain suspended for <code class="code">d</code> seconds
and then terminates.<br>
</div>
<pre><span id="VALyield"><span class="keyword">val</span> yield</span> : <code class="type">unit -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">yield ()</code> is a threads which suspends itself and then resumes
as soon as possible and terminates.<br>
</div>
<pre><span id="VALauto_yield"><span class="keyword">val</span> auto_yield</span> : <code class="type">float -> unit -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">auto_yield timeout</code> returns a function <code class="code">f</code> which will yield
every <code class="code">timeout</code> seconds.<br>
</div>
<pre><span id="EXCEPTIONTimeout"><span class="keyword">exception</span> Timeout</span></pre>
<div class="info ">
Exception raised by timeout operations<br>
</div>
<pre><span id="VALtimeout"><span class="keyword">val</span> timeout</span> : <code class="type">float -> 'a <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">timeout d</code> is a thread which remains suspended for <code class="code">d</code> seconds
then fails with <a href="Lwt_unix.html#EXCEPTIONTimeout"><code class="code"><span class="constructor">Lwt_unix</span>.<span class="constructor">Timeout</span></code></a><br>
</div>
<pre><span id="VALwith_timeout"><span class="keyword">val</span> with_timeout</span> : <code class="type">float -> (unit -> 'a <a href="Lwt.html#TYPEt">Lwt.t</a>) -> 'a <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">with_timeout d f</code> is a short-hand for:
<p>
<pre class="codepre"><code class="code"> <span class="constructor">Lwt</span>.pick [<span class="constructor">Lwt_unix</span>.timeout d; f ()]<br>
</code></pre><br>
</div>
<br>
<h6 id="6_Operationonfiledescriptors">Operation on file-descriptors</h6><br>
<pre><span id="TYPEfile_descr"><span class="keyword">type</span> <code class="type"></code>file_descr</span> </pre>
<div class="info ">
The abstract type for <b>file descriptor</b>s. A Lwt <b>file
descriptor</b> is a pair of a unix <b>file descriptor</b> (of type
<code class="code"><span class="constructor">Unix</span>.file_descr</code>) and a <b>state</b>.
<p>
A <b>file descriptor</b> may be:
<p>
<ul>
<li><b>opened</b>, in which case it is fully usable</li>
<li><b>closed</b> or <b>aborted</b>, in which case it is no longer
usable</li>
</ul>
<br>
</div>
<pre><code><span id="TYPEstate"><span class="keyword">type</span> <code class="type"></code>state</span> = </code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstate.Opened"><span class="constructor">Opened</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The <b>file descriptor</b> is opened</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstate.Closed"><span class="constructor">Closed</span></span></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The <b>file descriptor</b> has been closed by <a href="Lwt_unix.html#VALclose"><code class="code"><span class="constructor">Lwt_unix</span>.close</code></a>. It must
not be used for any operation.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstate.Aborted"><span class="constructor">Aborted</span></span> <span class="keyword">of</span> <code class="type">exn</code></code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The <b>file descriptor</b> has been aborted, the only operation
possible is <a href="Lwt_unix.html#VALclose"><code class="code"><span class="constructor">Lwt_unix</span>.close</code></a>, all others will fail.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
<div class="info ">
State of a <b>file descriptor</b><br>
</div>
<pre><span id="VALstate"><span class="keyword">val</span> state</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEstate">state</a></code></pre><div class="info ">
<code class="code">state fd</code> returns the state of <code class="code">fd</code><br>
</div>
<pre><span id="VALunix_file_descr"><span class="keyword">val</span> unix_file_descr</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> Unix.file_descr</code></pre><div class="info ">
Returns the underlying unix <b>file descriptor</b>. It always
succeeds, even if the <b>file descriptor</b>'s state is not
<code class="code"><span class="constructor">Open</span></code>.<br>
</div>
<pre><span id="VALof_unix_file_descr"><span class="keyword">val</span> of_unix_file_descr</span> : <code class="type">?blocking:bool -> ?set_flags:bool -> Unix.file_descr -> <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a></code></pre><div class="info ">
Creates a lwt <b>file descriptor</b> from a unix one.
<p>
<code class="code">blocking</code> is the blocking mode of the file-descriptor, and
describes how Lwt will use it. In non-blocking mode, read/write
on this file descriptor are made using non-blocking IO; in
blocking mode they are made using the current async method. If
<code class="code">blocking</code> is not specified it is guessed according to the file
kind: socket and pipes are in non-blocking mode and others are
in blocking mode.
<p>
If <code class="code">set_flags</code> is <code class="code"><span class="keyword">true</span></code> (the default) then the file flags are
modified according to the <code class="code">blocking</code> argument, otherwise they
are left unchanged.
<p>
Note that the blocking mode is less efficient than the
non-blocking one, so it should be used only for file descriptors
that does not support asynchronous operations, such as regular
files, or for shared descriptors such as <a href="Lwt_unix.html#VALstdout"><code class="code"><span class="constructor">Lwt_unix</span>.stdout</code></a>, <a href="Lwt_unix.html#VALstderr"><code class="code"><span class="constructor">Lwt_unix</span>.stderr</code></a> or
<a href="Lwt_unix.html#VALstdin"><code class="code"><span class="constructor">Lwt_unix</span>.stdin</code></a>.<br>
</div>
<pre><span id="VALblocking"><span class="keyword">val</span> blocking</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> bool <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">blocking fd</code> returns whether <code class="code">fd</code> is used in blocking or
non-blocking mode.<br>
</div>
<pre><span id="VALset_blocking"><span class="keyword">val</span> set_blocking</span> : <code class="type">?set_flags:bool -> <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> bool -> unit</code></pre><div class="info ">
<code class="code">set_blocking fd b</code> puts <code class="code">fd</code> in blocking or non-blocking
mode. If <code class="code">set_flags</code> is <code class="code"><span class="keyword">true</span></code> (the default) then the file flags
are modified, otherwise the modification is only done at the
application level.<br>
</div>
<pre><span id="VALabort"><span class="keyword">val</span> abort</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> exn -> unit</code></pre><div class="info ">
<code class="code">abort fd exn</code> makes all current and further uses of the file
descriptor fail with the given exception. This put the <b>file
descriptor</b> into the <code class="code"><span class="constructor">Aborted</span></code> state.
<p>
If the <b>file descriptor</b> is closed, this does nothing, if it is
aborted, this replace the abort exception by <code class="code">exn</code>.
<p>
Note that this only works for reading and writing operations on
file descriptors supporting non-blocking mode.<br>
</div>
<br>
<h6 id="6_Processhandling">Process handling</h6><br>
<pre><span id="VALfork"><span class="keyword">val</span> fork</span> : <code class="type">unit -> int</code></pre><div class="info ">
<code class="code">fork ()</code> does the same as <code class="code"><span class="constructor">Unix</span>.fork</code>. You must use this
function instead of <code class="code"><span class="constructor">Unix</span>.fork</code> when you want to use Lwt in the
child process.
<p>
Notes:<ul>
<li>in the child process all pending jobs are canceled,</li>
<li>if you are going to use Lwt in the parent and the child, it is
a good idea to call <a href="Lwt_io.html#VALflush_all"><code class="code"><span class="constructor">Lwt_io</span>.flush_all</code></a> before callling
<a href="Lwt_unix.html#VALfork"><code class="code"><span class="constructor">Lwt_unix</span>.fork</code></a> to avoid double-flush.</li>
</ul>
<br>
</div>
<pre><span id="TYPEprocess_status"><span class="keyword">type</span> <code class="type"></code>process_status</span> = <code class="type">Unix.process_status</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTprocess_status.WEXITED"><span class="constructor">WEXITED</span></span> <span class="keyword">of</span> <code class="type">int</code></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTprocess_status.WSIGNALED"><span class="constructor">WSIGNALED</span></span> <span class="keyword">of</span> <code class="type">int</code></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTprocess_status.WSTOPPED"><span class="constructor">WSTOPPED</span></span> <span class="keyword">of</span> <code class="type">int</code></code></td>
</tr></table>
<pre><span id="TYPEwait_flag"><span class="keyword">type</span> <code class="type"></code>wait_flag</span> = <code class="type">Unix.wait_flag</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTwait_flag.WNOHANG"><span class="constructor">WNOHANG</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTwait_flag.WUNTRACED"><span class="constructor">WUNTRACED</span></span></code></td>
</tr></table>
<pre><span id="VALwait"><span class="keyword">val</span> wait</span> : <code class="type">unit -> (int * <a href="Lwt_unix.html#TYPEprocess_status">process_status</a>) <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.wait</code><br>
</div>
<pre><span id="VALwaitpid"><span class="keyword">val</span> waitpid</span> : <code class="type"><a href="Lwt_unix.html#TYPEwait_flag">wait_flag</a> list -> int -> (int * <a href="Lwt_unix.html#TYPEprocess_status">process_status</a>) <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.waitpid</code><br>
</div>
<pre><code><span id="TYPEresource_usage"><span class="keyword">type</span> <code class="type"></code>resource_usage</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTresource_usage.ru_utime">ru_utime</span> : <code class="type">float</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >User time used</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTresource_usage.ru_stime">ru_stime</span> : <code class="type">float</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >System time used</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
}
<div class="info ">
Resource usages<br>
</div>
<pre><span id="VALwait4"><span class="keyword">val</span> wait4</span> : <code class="type"><a href="Lwt_unix.html#TYPEwait_flag">wait_flag</a> list -><br> int -> (int * <a href="Lwt_unix.html#TYPEprocess_status">process_status</a> * <a href="Lwt_unix.html#TYPEresource_usage">resource_usage</a>) <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">wait4 flags pid</code> returns <code class="code">(pid, status, rusage)</code> where <code class="code">(pid,
status)</code> is the same result as <code class="code"><span class="constructor">Unix</span>.waitpid flags pid</code>, and
<code class="code">rusage</code> contains accounting information about the child.
<p>
On windows it will always returns <code class="code">{ utime = 0.0; stime = 0.0 }</code>.<br>
</div>
<pre><span id="VALwait_count"><span class="keyword">val</span> wait_count</span> : <code class="type">unit -> int</code></pre><div class="info ">
Returns the number of threads waiting for a child to
terminate.<br>
</div>
<pre><span id="VALsystem"><span class="keyword">val</span> system</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEprocess_status">process_status</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Executes the given command, waits until it terminates, and
return its termination status. The string is interpreted by the
shell <code class="code">/bin/sh</code> on Unix and <code class="code">cmd.exe</code> on Windows. The result
<code class="code"><span class="constructor">WEXITED</span> 127</code> indicates that the shell couldn't be executed.<br>
</div>
<br>
<h6 id="6_Basicfileinputoutput">Basic file input/output</h6><br>
<pre><span id="VALstdin"><span class="keyword">val</span> stdin</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a></code></pre><div class="info ">
The standard <b>file descriptor</b> for input. This one is usually
a terminal is the program is started from a terminal.<br>
</div>
<pre><span id="VALstdout"><span class="keyword">val</span> stdout</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a></code></pre><div class="info ">
The standard <b>file descriptor</b> for output<br>
</div>
<pre><span id="VALstderr"><span class="keyword">val</span> stderr</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a></code></pre><div class="info ">
The standard <b>file descriptor</b> for printing error messages<br>
</div>
<pre><span id="TYPEfile_perm"><span class="keyword">type</span> <code class="type"></code>file_perm</span> = <code class="type">Unix.file_perm</code> </pre>
<pre><span id="TYPEopen_flag"><span class="keyword">type</span> <code class="type"></code>open_flag</span> = <code class="type">Unix.open_flag</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_RDONLY"><span class="constructor">O_RDONLY</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_WRONLY"><span class="constructor">O_WRONLY</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_RDWR"><span class="constructor">O_RDWR</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_NONBLOCK"><span class="constructor">O_NONBLOCK</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_APPEND"><span class="constructor">O_APPEND</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_CREAT"><span class="constructor">O_CREAT</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_TRUNC"><span class="constructor">O_TRUNC</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_EXCL"><span class="constructor">O_EXCL</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_NOCTTY"><span class="constructor">O_NOCTTY</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_DSYNC"><span class="constructor">O_DSYNC</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_SYNC"><span class="constructor">O_SYNC</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_RSYNC"><span class="constructor">O_RSYNC</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_SHARE_DELETE"><span class="constructor">O_SHARE_DELETE</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTopen_flag.O_CLOEXEC"><span class="constructor">O_CLOEXEC</span></span></code></td>
</tr></table>
<pre><span id="VALopenfile"><span class="keyword">val</span> openfile</span> : <code class="type">string -><br> <a href="Lwt_unix.html#TYPEopen_flag">open_flag</a> list -> <a href="Lwt_unix.html#TYPEfile_perm">file_perm</a> -> <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.openfile</code>.<br>
</div>
<pre><span id="VALclose"><span class="keyword">val</span> close</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Close a <b>file descriptor</b>. This close the underlying unix <b> file descriptor</b> and set its state to <code class="code"><span class="constructor">Closed</span></code><br>
</div>
<pre><span id="VALread"><span class="keyword">val</span> read</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> string -> int -> int -> int <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">read fd buf ofs len</code> has the same semantic as <code class="code"><span class="constructor">Unix</span>.read</code>, but
is cooperative<br>
</div>
<pre><span id="VALwrite"><span class="keyword">val</span> write</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> string -> int -> int -> int <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">read fd buf ofs len</code> has the same semantic as <code class="code"><span class="constructor">Unix</span>.write</code>, but
is cooperative<br>
</div>
<pre><span id="VALreadable"><span class="keyword">val</span> readable</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> bool</code></pre><div class="info ">
Returns whether the given file descriptor is currently
readable.<br>
</div>
<pre><span id="VALwritable"><span class="keyword">val</span> writable</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> bool</code></pre><div class="info ">
Returns whether the given file descriptor is currently
writable.<br>
</div>
<pre><span id="VALwait_read"><span class="keyword">val</span> wait_read</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
waits (without blocking other threads) until there is something
to read on the file descriptor<br>
</div>
<pre><span id="VALwait_write"><span class="keyword">val</span> wait_write</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
waits (without blocking other threads) until it is possible to
write on the file descriptor<br>
</div>
<br>
<h6 id="6_Seekingandtruncating">Seeking and truncating</h6><br>
<pre><span id="TYPEseek_command"><span class="keyword">type</span> <code class="type"></code>seek_command</span> = <code class="type">Unix.seek_command</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTseek_command.SEEK_SET"><span class="constructor">SEEK_SET</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTseek_command.SEEK_CUR"><span class="constructor">SEEK_CUR</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTseek_command.SEEK_END"><span class="constructor">SEEK_END</span></span></code></td>
</tr></table>
<pre><span id="VALlseek"><span class="keyword">val</span> lseek</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> int -> <a href="Lwt_unix.html#TYPEseek_command">seek_command</a> -> int <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.lseek</code><br>
</div>
<pre><span id="VALtruncate"><span class="keyword">val</span> truncate</span> : <code class="type">string -> int -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.truncate</code><br>
</div>
<pre><span id="VALftruncate"><span class="keyword">val</span> ftruncate</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> int -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.ftruncate</code><br>
</div>
<br>
<h6 id="6_Syncing">Syncing</h6><br>
<pre><span id="VALfsync"><span class="keyword">val</span> fsync</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Synchronise all data and metadata of the file descriptor with
the disk. On Windows it uses <code class="code"><span class="constructor">FlushFileBuffers</span></code>.<br>
</div>
<pre><span id="VALfdatasync"><span class="keyword">val</span> fdatasync</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Synchronise all data (but not metadata) of the file descriptor
with the disk.
<p>
Note that <code class="code">fdatasync</code> is not available on all platforms.<br>
</div>
<br>
<h6 id="6_Filestatus">File status</h6><br>
<pre><span id="TYPEfile_kind"><span class="keyword">type</span> <code class="type"></code>file_kind</span> = <code class="type">Unix.file_kind</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTfile_kind.S_REG"><span class="constructor">S_REG</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTfile_kind.S_DIR"><span class="constructor">S_DIR</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTfile_kind.S_CHR"><span class="constructor">S_CHR</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTfile_kind.S_BLK"><span class="constructor">S_BLK</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTfile_kind.S_LNK"><span class="constructor">S_LNK</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTfile_kind.S_FIFO"><span class="constructor">S_FIFO</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTfile_kind.S_SOCK"><span class="constructor">S_SOCK</span></span></code></td>
</tr></table>
<pre><span id="TYPEstats"><span class="keyword">type</span> <code class="type"></code>stats</span> = <code class="type">Unix.stats</code> = {</pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_dev">st_dev</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_ino">st_ino</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_kind">st_kind</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_kind">file_kind</a></code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_perm">st_perm</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_perm">file_perm</a></code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_nlink">st_nlink</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_uid">st_uid</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_gid">st_gid</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_rdev">st_rdev</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_size">st_size</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_atime">st_atime</span> : <code class="type">float</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_mtime">st_mtime</span> : <code class="type">float</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstats.st_ctime">st_ctime</span> : <code class="type">float</code>;</code></td>
</tr></table>
}
<pre><span id="VALstat"><span class="keyword">val</span> stat</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEstats">stats</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.stat</code><br>
</div>
<pre><span id="VALlstat"><span class="keyword">val</span> lstat</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEstats">stats</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.lstat</code><br>
</div>
<pre><span id="VALfstat"><span class="keyword">val</span> fstat</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEstats">stats</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.fstat</code><br>
</div>
<pre><span id="VALisatty"><span class="keyword">val</span> isatty</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> bool <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.isatty</code><br>
</div>
<br>
<h6 id="6_Fileoperationsonlargefiles">File operations on large files</h6><br>
<pre><span class="keyword">module</span> <a href="Lwt_unix.LargeFile.html">LargeFile</a>: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_unix.LargeFile.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><br>
<h6 id="6_Operationsonfilenames">Operations on file names</h6><br>
<pre><span id="VALunlink"><span class="keyword">val</span> unlink</span> : <code class="type">string -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.unlink</code><br>
</div>
<pre><span id="VALrename"><span class="keyword">val</span> rename</span> : <code class="type">string -> string -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.rename</code><br>
</div>
<pre><span id="VALlink"><span class="keyword">val</span> link</span> : <code class="type">string -> string -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.link</code><br>
</div>
<br>
<h6 id="6_Filepermissionsandownership">File permissions and ownership</h6><br>
<pre><span id="VALchmod"><span class="keyword">val</span> chmod</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEfile_perm">file_perm</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.chmod</code><br>
</div>
<pre><span id="VALfchmod"><span class="keyword">val</span> fchmod</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEfile_perm">file_perm</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.fchmod</code><br>
</div>
<pre><span id="VALchown"><span class="keyword">val</span> chown</span> : <code class="type">string -> int -> int -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.chown</code><br>
</div>
<pre><span id="VALfchown"><span class="keyword">val</span> fchown</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> int -> int -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.fchown</code><br>
</div>
<pre><span id="TYPEaccess_permission"><span class="keyword">type</span> <code class="type"></code>access_permission</span> = <code class="type">Unix.access_permission</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTaccess_permission.R_OK"><span class="constructor">R_OK</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTaccess_permission.W_OK"><span class="constructor">W_OK</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTaccess_permission.X_OK"><span class="constructor">X_OK</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTaccess_permission.F_OK"><span class="constructor">F_OK</span></span></code></td>
</tr></table>
<pre><span id="VALaccess"><span class="keyword">val</span> access</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEaccess_permission">access_permission</a> list -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.access</code><br>
</div>
<br>
<h6 id="6_Operationsonfiledescriptors">Operations on file descriptors</h6><br>
<pre><span id="VALdup"><span class="keyword">val</span> dup</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.dup</code><br>
</div>
<pre><span id="VALdup2"><span class="keyword">val</span> dup2</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> unit</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.dup2</code><br>
</div>
<pre><span id="VALset_close_on_exec"><span class="keyword">val</span> set_close_on_exec</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> unit</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.set_close_on_exec</code><br>
</div>
<pre><span id="VALclear_close_on_exec"><span class="keyword">val</span> clear_close_on_exec</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> unit</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.clear_close_on_exec</code><br>
</div>
<br>
<h6 id="6_Directories">Directories</h6><br>
<pre><span id="VALmkdir"><span class="keyword">val</span> mkdir</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEfile_perm">file_perm</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.mkdir</code><br>
</div>
<pre><span id="VALrmdir"><span class="keyword">val</span> rmdir</span> : <code class="type">string -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.rmdir</code><br>
</div>
<pre><span id="VALchdir"><span class="keyword">val</span> chdir</span> : <code class="type">string -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.chdir</code><br>
</div>
<pre><span id="VALchroot"><span class="keyword">val</span> chroot</span> : <code class="type">string -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.chroot</code><br>
</div>
<pre><span id="TYPEdir_handle"><span class="keyword">type</span> <code class="type"></code>dir_handle</span> = <code class="type">Unix.dir_handle</code> </pre>
<pre><span id="VALopendir"><span class="keyword">val</span> opendir</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEdir_handle">dir_handle</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.opendir</code><br>
</div>
<pre><span id="VALreaddir"><span class="keyword">val</span> readdir</span> : <code class="type"><a href="Lwt_unix.html#TYPEdir_handle">dir_handle</a> -> string <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.dir</code><br>
</div>
<pre><span id="VALreaddir_n"><span class="keyword">val</span> readdir_n</span> : <code class="type"><a href="Lwt_unix.html#TYPEdir_handle">dir_handle</a> -> int -> string array <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">readdir_n handle count</code> reads at most <code class="code">count</code> entry from the
given directory. It is more efficient than calling <code class="code">readdir</code>
<code class="code">count</code> times. If the length of the returned array is smaller
than <code class="code">count</code>, this means that the end of the directory has been
reached.<br>
</div>
<pre><span id="VALrewinddir"><span class="keyword">val</span> rewinddir</span> : <code class="type"><a href="Lwt_unix.html#TYPEdir_handle">dir_handle</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.rewinddir</code><br>
</div>
<pre><span id="VALclosedir"><span class="keyword">val</span> closedir</span> : <code class="type"><a href="Lwt_unix.html#TYPEdir_handle">dir_handle</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.closedir</code><br>
</div>
<pre><span id="VALfiles_of_directory"><span class="keyword">val</span> files_of_directory</span> : <code class="type">string -> string <a href="Lwt_stream.html#TYPEt">Lwt_stream.t</a></code></pre><div class="info ">
<code class="code">files_of_directory dir</code> returns the stream of all files of
<code class="code">dir</code>.<br>
</div>
<br>
<h6 id="6_Pipesandredirections">Pipes and redirections</h6><br>
<pre><span id="VALpipe"><span class="keyword">val</span> pipe</span> : <code class="type">unit -> <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> * <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a></code></pre><div class="info ">
<code class="code">pipe ()</code> creates pipe using <code class="code"><span class="constructor">Unix</span>.pipe</code> and returns two lwt <b> file descriptor</b>s created from unix <b>file_descriptor</b><br>
</div>
<pre><span id="VALpipe_in"><span class="keyword">val</span> pipe_in</span> : <code class="type">unit -> <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> * Unix.file_descr</code></pre><div class="info ">
<code class="code">pipe_in ()</code> is the same as <a href="Lwt_unix.html#VALpipe"><code class="code"><span class="constructor">Lwt_unix</span>.pipe</code></a> but maps only the unix <b> file descriptor</b> for reading into a lwt one. The second is not
put into non-blocking mode. You usually want to use this before
forking to receive data from the child process.<br>
</div>
<pre><span id="VALpipe_out"><span class="keyword">val</span> pipe_out</span> : <code class="type">unit -> Unix.file_descr * <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a></code></pre><div class="info ">
<code class="code">pipe_out ()</code> is the inverse of <a href="Lwt_unix.html#VALpipe_in"><code class="code"><span class="constructor">Lwt_unix</span>.pipe_in</code></a>. You usually want to
use this before forking to send data to the child process<br>
</div>
<pre><span id="VALmkfifo"><span class="keyword">val</span> mkfifo</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEfile_perm">file_perm</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.mkfifo</code><br>
</div>
<br>
<h6 id="6_Symboliclinks">Symbolic links</h6><br>
<pre><span id="VALsymlink"><span class="keyword">val</span> symlink</span> : <code class="type">string -> string -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.symlink</code><br>
</div>
<pre><span id="VALreadlink"><span class="keyword">val</span> readlink</span> : <code class="type">string -> string <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.readlink</code><br>
</div>
<br>
<h6 id="6_Locking">Locking</h6><br>
<pre><span id="TYPElock_command"><span class="keyword">type</span> <code class="type"></code>lock_command</span> = <code class="type">Unix.lock_command</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTlock_command.F_ULOCK"><span class="constructor">F_ULOCK</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTlock_command.F_LOCK"><span class="constructor">F_LOCK</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTlock_command.F_TLOCK"><span class="constructor">F_TLOCK</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTlock_command.F_TEST"><span class="constructor">F_TEST</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTlock_command.F_RLOCK"><span class="constructor">F_RLOCK</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTlock_command.F_TRLOCK"><span class="constructor">F_TRLOCK</span></span></code></td>
</tr></table>
<pre><span id="VALlockf"><span class="keyword">val</span> lockf</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPElock_command">lock_command</a> -> int -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.lockf</code><br>
</div>
<br>
<h6 id="6_Useridgroupid">User id, group id</h6><br>
<pre><span id="TYPEpasswd_entry"><span class="keyword">type</span> <code class="type"></code>passwd_entry</span> = <code class="type">Unix.passwd_entry</code> = {</pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTpasswd_entry.pw_name">pw_name</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTpasswd_entry.pw_passwd">pw_passwd</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTpasswd_entry.pw_uid">pw_uid</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTpasswd_entry.pw_gid">pw_gid</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTpasswd_entry.pw_gecos">pw_gecos</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTpasswd_entry.pw_dir">pw_dir</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTpasswd_entry.pw_shell">pw_shell</span> : <code class="type">string</code>;</code></td>
</tr></table>
}
<pre><span id="TYPEgroup_entry"><span class="keyword">type</span> <code class="type"></code>group_entry</span> = <code class="type">Unix.group_entry</code> = {</pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgroup_entry.gr_name">gr_name</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgroup_entry.gr_passwd">gr_passwd</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgroup_entry.gr_gid">gr_gid</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgroup_entry.gr_mem">gr_mem</span> : <code class="type">string array</code>;</code></td>
</tr></table>
}
<pre><span id="VALgetlogin"><span class="keyword">val</span> getlogin</span> : <code class="type">unit -> string <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getlogin</code><br>
</div>
<pre><span id="VALgetpwnam"><span class="keyword">val</span> getpwnam</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEpasswd_entry">passwd_entry</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getpwnam</code><br>
</div>
<pre><span id="VALgetgrnam"><span class="keyword">val</span> getgrnam</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEgroup_entry">group_entry</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getgrnam</code><br>
</div>
<pre><span id="VALgetpwuid"><span class="keyword">val</span> getpwuid</span> : <code class="type">int -> <a href="Lwt_unix.html#TYPEpasswd_entry">passwd_entry</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getpwuid</code><br>
</div>
<pre><span id="VALgetgrgid"><span class="keyword">val</span> getgrgid</span> : <code class="type">int -> <a href="Lwt_unix.html#TYPEgroup_entry">group_entry</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getgrgid</code><br>
</div>
<br>
<h6 id="6_Signals">Signals</h6><br>
<pre><span id="TYPEsignal_handler_id"><span class="keyword">type</span> <code class="type"></code>signal_handler_id</span> </pre>
<div class="info ">
Id of a signal handler, used to cancel it<br>
</div>
<pre><span id="VALon_signal"><span class="keyword">val</span> on_signal</span> : <code class="type">int -> (int -> unit) -> <a href="Lwt_unix.html#TYPEsignal_handler_id">signal_handler_id</a></code></pre><div class="info ">
<code class="code">on_signal signum f</code> calls <code class="code">f</code> each time the signal with numnber
<code class="code">signum</code> is received by the process. It returns a signal handler
identifier which can be used to stop monitoring <code class="code">signum</code>.<br>
</div>
<pre><span id="VALon_signal_full"><span class="keyword">val</span> on_signal_full</span> : <code class="type">int -><br> (<a href="Lwt_unix.html#TYPEsignal_handler_id">signal_handler_id</a> -> int -> unit) -> <a href="Lwt_unix.html#TYPEsignal_handler_id">signal_handler_id</a></code></pre><div class="info ">
<code class="code">on_signal_full f</code> is the same as <code class="code">on_signal f</code> except that <code class="code">f</code>
also receive the signal handler identifier as argument so it can
disable it.<br>
</div>
<pre><span id="VALdisable_signal_handler"><span class="keyword">val</span> disable_signal_handler</span> : <code class="type"><a href="Lwt_unix.html#TYPEsignal_handler_id">signal_handler_id</a> -> unit</code></pre><div class="info ">
Stops receiving this signal<br>
</div>
<pre><span id="VALsignal_count"><span class="keyword">val</span> signal_count</span> : <code class="type">unit -> int</code></pre><div class="info ">
Returns the number of registered signal handler.<br>
</div>
<pre><span id="VALreinstall_signal_handler"><span class="keyword">val</span> reinstall_signal_handler</span> : <code class="type">int -> unit</code></pre><div class="info ">
<code class="code">reinstall_signal_handler signum</code> if any signal handler is
registered for this signal with <a href="Lwt_unix.html#VALon_signal"><code class="code"><span class="constructor">Lwt_unix</span>.on_signal</code></a>, it reinstall the
signal handler (with <code class="code"><span class="constructor">Sys</span>.set_signal</code>). This is usefull in case
another part of the program install another signal handler.<br>
</div>
<br>
<h6 id="6_Sockets">Sockets</h6><br>
<pre><span id="TYPEinet_addr"><span class="keyword">type</span> <code class="type"></code>inet_addr</span> = <code class="type">Unix.inet_addr</code> </pre>
<pre><span id="TYPEsocket_domain"><span class="keyword">type</span> <code class="type"></code>socket_domain</span> = <code class="type">Unix.socket_domain</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_domain.PF_UNIX"><span class="constructor">PF_UNIX</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_domain.PF_INET"><span class="constructor">PF_INET</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_domain.PF_INET6"><span class="constructor">PF_INET6</span></span></code></td>
</tr></table>
<pre><span id="TYPEsocket_type"><span class="keyword">type</span> <code class="type"></code>socket_type</span> = <code class="type">Unix.socket_type</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_type.SOCK_STREAM"><span class="constructor">SOCK_STREAM</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_type.SOCK_DGRAM"><span class="constructor">SOCK_DGRAM</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_type.SOCK_RAW"><span class="constructor">SOCK_RAW</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_type.SOCK_SEQPACKET"><span class="constructor">SOCK_SEQPACKET</span></span></code></td>
</tr></table>
<pre><span id="TYPEsockaddr"><span class="keyword">type</span> <code class="type"></code>sockaddr</span> = <code class="type">Unix.sockaddr</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsockaddr.ADDR_UNIX"><span class="constructor">ADDR_UNIX</span></span> <span class="keyword">of</span> <code class="type">string</code></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsockaddr.ADDR_INET"><span class="constructor">ADDR_INET</span></span> <span class="keyword">of</span> <code class="type"><a href="Lwt_unix.html#TYPEinet_addr">inet_addr</a> * int</code></code></td>
</tr></table>
<pre><span id="VALsocket"><span class="keyword">val</span> socket</span> : <code class="type"><a href="Lwt_unix.html#TYPEsocket_domain">socket_domain</a> -> <a href="Lwt_unix.html#TYPEsocket_type">socket_type</a> -> int -> <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a></code></pre><div class="info ">
<code class="code">socket domain <span class="keyword">type</span> proto</code> is the same as <code class="code"><span class="constructor">Unix</span>.socket</code> but maps
the result into a lwt <b>file descriptor</b><br>
</div>
<pre><span id="VALsocketpair"><span class="keyword">val</span> socketpair</span> : <code class="type"><a href="Lwt_unix.html#TYPEsocket_domain">socket_domain</a> -><br> <a href="Lwt_unix.html#TYPEsocket_type">socket_type</a> -> int -> <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> * <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.socketpair</code><br>
</div>
<pre><span id="VALbind"><span class="keyword">val</span> bind</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsockaddr">sockaddr</a> -> unit</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.bind</code><br>
</div>
<pre><span id="VALlisten"><span class="keyword">val</span> listen</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> int -> unit</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.listen</code><br>
</div>
<pre><span id="VALaccept"><span class="keyword">val</span> accept</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> (<a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> * <a href="Lwt_unix.html#TYPEsockaddr">sockaddr</a>) <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.accept</code><br>
</div>
<pre><span id="VALaccept_n"><span class="keyword">val</span> accept_n</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -><br> int -> ((<a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> * <a href="Lwt_unix.html#TYPEsockaddr">sockaddr</a>) list * exn option) <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">accept_n fd count</code> accepts up to <code class="code">count</code> connection in one time.
<p>
<ul>
<li>if no connection is available right now, it returns a sleeping
thread</li>
</ul>
<ul>
<li>if more that 1 and less than <code class="code">count</code> are available, it returns
all of them</li>
</ul>
<ul>
<li>if more that <code class="code">count</code> are available, it returns the next
<code class="code">count</code> of them</li>
</ul>
<ul>
<li>if an error happen, it returns the connections that have been
successfully accepted so far and the error</li>
</ul>
<code class="code">accept_n</code> has the advantage of improving performances. If you
want a more detailed description, you can have a look at:
<p>
<a href="http://portal.acm.org/citation.cfm?id=1247435">Acceptable strategies for improving web server performance</a><br>
</div>
<pre><span id="VALconnect"><span class="keyword">val</span> connect</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsockaddr">sockaddr</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.connect</code><br>
</div>
<pre><span id="TYPEshutdown_command"><span class="keyword">type</span> <code class="type"></code>shutdown_command</span> = <code class="type">Unix.shutdown_command</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTshutdown_command.SHUTDOWN_RECEIVE"><span class="constructor">SHUTDOWN_RECEIVE</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTshutdown_command.SHUTDOWN_SEND"><span class="constructor">SHUTDOWN_SEND</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTshutdown_command.SHUTDOWN_ALL"><span class="constructor">SHUTDOWN_ALL</span></span></code></td>
</tr></table>
<pre><span id="VALshutdown"><span class="keyword">val</span> shutdown</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEshutdown_command">shutdown_command</a> -> unit</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.shutdown</code><br>
</div>
<pre><span id="VALgetsockname"><span class="keyword">val</span> getsockname</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsockaddr">sockaddr</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getsockname</code><br>
</div>
<pre><span id="VALgetpeername"><span class="keyword">val</span> getpeername</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsockaddr">sockaddr</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getpeername</code><br>
</div>
<pre><span id="TYPEmsg_flag"><span class="keyword">type</span> <code class="type"></code>msg_flag</span> = <code class="type">Unix.msg_flag</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTmsg_flag.MSG_OOB"><span class="constructor">MSG_OOB</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTmsg_flag.MSG_DONTROUTE"><span class="constructor">MSG_DONTROUTE</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTmsg_flag.MSG_PEEK"><span class="constructor">MSG_PEEK</span></span></code></td>
</tr></table>
<pre><span id="VALrecv"><span class="keyword">val</span> recv</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -><br> string -> int -> int -> <a href="Lwt_unix.html#TYPEmsg_flag">msg_flag</a> list -> int <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.recv</code><br>
</div>
<pre><span id="VALrecvfrom"><span class="keyword">val</span> recvfrom</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -><br> string -><br> int -> int -> <a href="Lwt_unix.html#TYPEmsg_flag">msg_flag</a> list -> (int * <a href="Lwt_unix.html#TYPEsockaddr">sockaddr</a>) <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.recvfrom</code><br>
</div>
<pre><span id="VALsend"><span class="keyword">val</span> send</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -><br> string -> int -> int -> <a href="Lwt_unix.html#TYPEmsg_flag">msg_flag</a> list -> int <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.send</code><br>
</div>
<pre><span id="VALsendto"><span class="keyword">val</span> sendto</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -><br> string -><br> int -> int -> <a href="Lwt_unix.html#TYPEmsg_flag">msg_flag</a> list -> <a href="Lwt_unix.html#TYPEsockaddr">sockaddr</a> -> int <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.sendto</code><br>
</div>
<pre><code><span id="TYPEio_vector"><span class="keyword">type</span> <code class="type"></code>io_vector</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTio_vector.iov_buffer">iov_buffer</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTio_vector.iov_offset">iov_offset</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTio_vector.iov_length">iov_length</span> : <code class="type">int</code>;</code></td>
</tr></table>
}
<div class="info ">
An io-vector. Used by <a href="Lwt_unix.html#VALrecv_msg"><code class="code"><span class="constructor">Lwt_unix</span>.recv_msg</code></a> and <a href="Lwt_unix.html#VALsend_msg"><code class="code"><span class="constructor">Lwt_unix</span>.send_msg</code></a>.<br>
</div>
<pre><span id="VALio_vector"><span class="keyword">val</span> io_vector</span> : <code class="type">buffer:string -> offset:int -> length:int -> <a href="Lwt_unix.html#TYPEio_vector">io_vector</a></code></pre><div class="info ">
Creates an io-vector<br>
</div>
<pre><span id="VALrecv_msg"><span class="keyword">val</span> recv_msg</span> : <code class="type">socket:<a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -><br> io_vectors:<a href="Lwt_unix.html#TYPEio_vector">io_vector</a> list -> (int * Unix.file_descr list) <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">recv_msg ~socket ~io_vectors</code> receives data into a list of
io-vectors, plus any file-descriptors that may accompany the
message.
<p>
This call is not available on windows.<br>
</div>
<pre><span id="VALsend_msg"><span class="keyword">val</span> send_msg</span> : <code class="type">socket:<a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -><br> io_vectors:<a href="Lwt_unix.html#TYPEio_vector">io_vector</a> list -> fds:Unix.file_descr list -> int <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">send_msg ~socket ~io_vectors ~fds</code> sends data from a list of
io-vectors, accompanied with a list of file-descriptor. If
fd-passing is not possible on the current system and <code class="code">fds</code> is
not empty, it raises <code class="code"><span class="constructor">Lwt_sys</span>.<span class="constructor">Not_available</span> <span class="string">"fd_passing"</span></code>.
<p>
This call is not available on windows.<br>
</div>
<pre><code><span id="TYPEcredentials"><span class="keyword">type</span> <code class="type"></code>credentials</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTcredentials.cred_pid">cred_pid</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTcredentials.cred_uid">cred_uid</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTcredentials.cred_gid">cred_gid</span> : <code class="type">int</code>;</code></td>
</tr></table>
}
<pre><span id="VALget_credentials"><span class="keyword">val</span> get_credentials</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEcredentials">credentials</a></code></pre><div class="info ">
<code class="code">get_credentials fd</code> returns credential informations from the
given socket. On some platforms, obtaining the peer pid is not
possible and it will be set to <code class="code">-1</code>. If obtaining credentials
is not possible on the current system, it raises
<code class="code"><span class="constructor">Lwt_sys</span>.<span class="constructor">Not_available</span> <span class="string">"get_credentials"</span></code>.
<p>
This call is not available on windows.<br>
</div>
<br>
<div class="h8" id="8_Socketoptions">Socket options</div><br>
<pre><span id="TYPEsocket_bool_option"><span class="keyword">type</span> <code class="type"></code>socket_bool_option</span> = <code class="type">Unix.socket_bool_option</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_bool_option.SO_DEBUG"><span class="constructor">SO_DEBUG</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_bool_option.SO_BROADCAST"><span class="constructor">SO_BROADCAST</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_bool_option.SO_REUSEADDR"><span class="constructor">SO_REUSEADDR</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_bool_option.SO_KEEPALIVE"><span class="constructor">SO_KEEPALIVE</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_bool_option.SO_DONTROUTE"><span class="constructor">SO_DONTROUTE</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_bool_option.SO_OOBINLINE"><span class="constructor">SO_OOBINLINE</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_bool_option.SO_ACCEPTCONN"><span class="constructor">SO_ACCEPTCONN</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_bool_option.TCP_NODELAY"><span class="constructor">TCP_NODELAY</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_bool_option.IPV6_ONLY"><span class="constructor">IPV6_ONLY</span></span></code></td>
</tr></table>
<pre><span id="TYPEsocket_int_option"><span class="keyword">type</span> <code class="type"></code>socket_int_option</span> = <code class="type">Unix.socket_int_option</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_int_option.SO_SNDBUF"><span class="constructor">SO_SNDBUF</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_int_option.SO_RCVBUF"><span class="constructor">SO_RCVBUF</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_int_option.SO_ERROR"><span class="constructor">SO_ERROR</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_int_option.SO_TYPE"><span class="constructor">SO_TYPE</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_int_option.SO_RCVLOWAT"><span class="constructor">SO_RCVLOWAT</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_int_option.SO_SNDLOWAT"><span class="constructor">SO_SNDLOWAT</span></span></code></td>
</tr></table>
<pre><span id="TYPEsocket_optint_option"><span class="keyword">type</span> <code class="type"></code>socket_optint_option</span> = <code class="type">Unix.socket_optint_option</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_optint_option.SO_LINGER"><span class="constructor">SO_LINGER</span></span></code></td>
</tr></table>
<pre><span id="TYPEsocket_float_option"><span class="keyword">type</span> <code class="type"></code>socket_float_option</span> = <code class="type">Unix.socket_float_option</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_float_option.SO_RCVTIMEO"><span class="constructor">SO_RCVTIMEO</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsocket_float_option.SO_SNDTIMEO"><span class="constructor">SO_SNDTIMEO</span></span></code></td>
</tr></table>
<pre><span id="VALgetsockopt"><span class="keyword">val</span> getsockopt</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsocket_bool_option">socket_bool_option</a> -> bool</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getsockopt</code><br>
</div>
<pre><span id="VALsetsockopt"><span class="keyword">val</span> setsockopt</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsocket_bool_option">socket_bool_option</a> -> bool -> unit</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.setsockopt</code><br>
</div>
<pre><span id="VALgetsockopt_int"><span class="keyword">val</span> getsockopt_int</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsocket_int_option">socket_int_option</a> -> int</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getsockopt_int</code><br>
</div>
<pre><span id="VALsetsockopt_int"><span class="keyword">val</span> setsockopt_int</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsocket_int_option">socket_int_option</a> -> int -> unit</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.setsockopt_int</code><br>
</div>
<pre><span id="VALgetsockopt_optint"><span class="keyword">val</span> getsockopt_optint</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsocket_optint_option">socket_optint_option</a> -> int option</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getsockopt_optint</code><br>
</div>
<pre><span id="VALsetsockopt_optint"><span class="keyword">val</span> setsockopt_optint</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsocket_optint_option">socket_optint_option</a> -> int option -> unit</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.setsockopt_optint</code><br>
</div>
<pre><span id="VALgetsockopt_float"><span class="keyword">val</span> getsockopt_float</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsocket_float_option">socket_float_option</a> -> float</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getsockopt_float</code><br>
</div>
<pre><span id="VALsetsockopt_float"><span class="keyword">val</span> setsockopt_float</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEsocket_float_option">socket_float_option</a> -> float -> unit</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.setsockopt_float</code><br>
</div>
<pre><span id="VALgetsockopt_error"><span class="keyword">val</span> getsockopt_error</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> Unix.error option</code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getsockopt_error</code><br>
</div>
<br>
<h6 id="6_Hostandprotocoldatabases">Host and protocol databases</h6><br>
<pre><span id="TYPEhost_entry"><span class="keyword">type</span> <code class="type"></code>host_entry</span> = <code class="type">Unix.host_entry</code> = {</pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELThost_entry.h_name">h_name</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELThost_entry.h_aliases">h_aliases</span> : <code class="type">string array</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELThost_entry.h_addrtype">h_addrtype</span> : <code class="type"><a href="Lwt_unix.html#TYPEsocket_domain">socket_domain</a></code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELThost_entry.h_addr_list">h_addr_list</span> : <code class="type"><a href="Lwt_unix.html#TYPEinet_addr">inet_addr</a> array</code>;</code></td>
</tr></table>
}
<pre><span id="TYPEprotocol_entry"><span class="keyword">type</span> <code class="type"></code>protocol_entry</span> = <code class="type">Unix.protocol_entry</code> = {</pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTprotocol_entry.p_name">p_name</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTprotocol_entry.p_aliases">p_aliases</span> : <code class="type">string array</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTprotocol_entry.p_proto">p_proto</span> : <code class="type">int</code>;</code></td>
</tr></table>
}
<pre><span id="TYPEservice_entry"><span class="keyword">type</span> <code class="type"></code>service_entry</span> = <code class="type">Unix.service_entry</code> = {</pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTservice_entry.s_name">s_name</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTservice_entry.s_aliases">s_aliases</span> : <code class="type">string array</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTservice_entry.s_port">s_port</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTservice_entry.s_proto">s_proto</span> : <code class="type">string</code>;</code></td>
</tr></table>
}
<pre><span id="VALgethostname"><span class="keyword">val</span> gethostname</span> : <code class="type">unit -> string <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.gethostname</code><br>
</div>
<pre><span id="VALgethostbyname"><span class="keyword">val</span> gethostbyname</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEhost_entry">host_entry</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.gethostbyname</code><br>
</div>
<pre><span id="VALgethostbyaddr"><span class="keyword">val</span> gethostbyaddr</span> : <code class="type"><a href="Lwt_unix.html#TYPEinet_addr">inet_addr</a> -> <a href="Lwt_unix.html#TYPEhost_entry">host_entry</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.gethostbyaddr</code><br>
</div>
<pre><span id="VALgetprotobyname"><span class="keyword">val</span> getprotobyname</span> : <code class="type">string -> <a href="Lwt_unix.html#TYPEprotocol_entry">protocol_entry</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getprotobyname</code><br>
</div>
<pre><span id="VALgetprotobynumber"><span class="keyword">val</span> getprotobynumber</span> : <code class="type">int -> <a href="Lwt_unix.html#TYPEprotocol_entry">protocol_entry</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getprotobynumber</code><br>
</div>
<pre><span id="VALgetservbyname"><span class="keyword">val</span> getservbyname</span> : <code class="type">string -> string -> <a href="Lwt_unix.html#TYPEservice_entry">service_entry</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getservbyname</code><br>
</div>
<pre><span id="VALgetservbyport"><span class="keyword">val</span> getservbyport</span> : <code class="type">int -> string -> <a href="Lwt_unix.html#TYPEservice_entry">service_entry</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getservbyport</code><br>
</div>
<pre><span id="TYPEaddr_info"><span class="keyword">type</span> <code class="type"></code>addr_info</span> = <code class="type">Unix.addr_info</code> = {</pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTaddr_info.ai_family">ai_family</span> : <code class="type"><a href="Lwt_unix.html#TYPEsocket_domain">socket_domain</a></code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTaddr_info.ai_socktype">ai_socktype</span> : <code class="type"><a href="Lwt_unix.html#TYPEsocket_type">socket_type</a></code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTaddr_info.ai_protocol">ai_protocol</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTaddr_info.ai_addr">ai_addr</span> : <code class="type"><a href="Lwt_unix.html#TYPEsockaddr">sockaddr</a></code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTaddr_info.ai_canonname">ai_canonname</span> : <code class="type">string</code>;</code></td>
</tr></table>
}
<pre><span id="TYPEgetaddrinfo_option"><span class="keyword">type</span> <code class="type"></code>getaddrinfo_option</span> = <code class="type">Unix.getaddrinfo_option</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgetaddrinfo_option.AI_FAMILY"><span class="constructor">AI_FAMILY</span></span> <span class="keyword">of</span> <code class="type"><a href="Lwt_unix.html#TYPEsocket_domain">socket_domain</a></code></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgetaddrinfo_option.AI_SOCKTYPE"><span class="constructor">AI_SOCKTYPE</span></span> <span class="keyword">of</span> <code class="type"><a href="Lwt_unix.html#TYPEsocket_type">socket_type</a></code></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgetaddrinfo_option.AI_PROTOCOL"><span class="constructor">AI_PROTOCOL</span></span> <span class="keyword">of</span> <code class="type">int</code></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgetaddrinfo_option.AI_NUMERICHOST"><span class="constructor">AI_NUMERICHOST</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgetaddrinfo_option.AI_CANONNAME"><span class="constructor">AI_CANONNAME</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgetaddrinfo_option.AI_PASSIVE"><span class="constructor">AI_PASSIVE</span></span></code></td>
</tr></table>
<pre><span id="VALgetaddrinfo"><span class="keyword">val</span> getaddrinfo</span> : <code class="type">string -><br> string -> <a href="Lwt_unix.html#TYPEgetaddrinfo_option">getaddrinfo_option</a> list -> <a href="Lwt_unix.html#TYPEaddr_info">addr_info</a> list <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getaddrinfo</code><br>
</div>
<pre><span id="TYPEname_info"><span class="keyword">type</span> <code class="type"></code>name_info</span> = <code class="type">Unix.name_info</code> = {</pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTname_info.ni_hostname">ni_hostname</span> : <code class="type">string</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTname_info.ni_service">ni_service</span> : <code class="type">string</code>;</code></td>
</tr></table>
}
<pre><span id="TYPEgetnameinfo_option"><span class="keyword">type</span> <code class="type"></code>getnameinfo_option</span> = <code class="type">Unix.getnameinfo_option</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgetnameinfo_option.NI_NOFQDN"><span class="constructor">NI_NOFQDN</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgetnameinfo_option.NI_NUMERICHOST"><span class="constructor">NI_NUMERICHOST</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgetnameinfo_option.NI_NAMEREQD"><span class="constructor">NI_NAMEREQD</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgetnameinfo_option.NI_NUMERICSERV"><span class="constructor">NI_NUMERICSERV</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTgetnameinfo_option.NI_DGRAM"><span class="constructor">NI_DGRAM</span></span></code></td>
</tr></table>
<pre><span id="VALgetnameinfo"><span class="keyword">val</span> getnameinfo</span> : <code class="type"><a href="Lwt_unix.html#TYPEsockaddr">sockaddr</a> -><br> <a href="Lwt_unix.html#TYPEgetnameinfo_option">getnameinfo_option</a> list -> <a href="Lwt_unix.html#TYPEname_info">name_info</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.getnameinfo</code><br>
</div>
<br>
<h6 id="6_Terminalinterface">Terminal interface</h6><br>
<pre><span id="TYPEterminal_io"><span class="keyword">type</span> <code class="type"></code>terminal_io</span> = <code class="type">Unix.terminal_io</code> = {</pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_ignbrk">c_ignbrk</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_brkint">c_brkint</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_ignpar">c_ignpar</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_parmrk">c_parmrk</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_inpck">c_inpck</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_istrip">c_istrip</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_inlcr">c_inlcr</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_igncr">c_igncr</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_icrnl">c_icrnl</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_ixon">c_ixon</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_ixoff">c_ixoff</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_opost">c_opost</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_obaud">c_obaud</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_ibaud">c_ibaud</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_csize">c_csize</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_cstopb">c_cstopb</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_cread">c_cread</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_parenb">c_parenb</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_parodd">c_parodd</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_hupcl">c_hupcl</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_clocal">c_clocal</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_isig">c_isig</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_icanon">c_icanon</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_noflsh">c_noflsh</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_echo">c_echo</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_echoe">c_echoe</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_echok">c_echok</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_echonl">c_echonl</span> : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_vintr">c_vintr</span> : <code class="type">char</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_vquit">c_vquit</span> : <code class="type">char</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_verase">c_verase</span> : <code class="type">char</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_vkill">c_vkill</span> : <code class="type">char</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_veof">c_veof</span> : <code class="type">char</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_veol">c_veol</span> : <code class="type">char</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_vmin">c_vmin</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_vtime">c_vtime</span> : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_vstart">c_vstart</span> : <code class="type">char</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTterminal_io.c_vstop">c_vstop</span> : <code class="type">char</code>;</code></td>
</tr></table>
}
<pre><span id="VALtcgetattr"><span class="keyword">val</span> tcgetattr</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEterminal_io">terminal_io</a> <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.tcgetattr</code><br>
</div>
<pre><span id="TYPEsetattr_when"><span class="keyword">type</span> <code class="type"></code>setattr_when</span> = <code class="type">Unix.setattr_when</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsetattr_when.TCSANOW"><span class="constructor">TCSANOW</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsetattr_when.TCSADRAIN"><span class="constructor">TCSADRAIN</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTsetattr_when.TCSAFLUSH"><span class="constructor">TCSAFLUSH</span></span></code></td>
</tr></table>
<pre><span id="VALtcsetattr"><span class="keyword">val</span> tcsetattr</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -><br> <a href="Lwt_unix.html#TYPEsetattr_when">setattr_when</a> -> <a href="Lwt_unix.html#TYPEterminal_io">terminal_io</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.tcsetattr</code><br>
</div>
<pre><span id="VALtcsendbreak"><span class="keyword">val</span> tcsendbreak</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> int -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.tcsendbreak</code><br>
</div>
<pre><span id="VALtcdrain"><span class="keyword">val</span> tcdrain</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.tcdrain</code><br>
</div>
<pre><span id="TYPEflush_queue"><span class="keyword">type</span> <code class="type"></code>flush_queue</span> = <code class="type">Unix.flush_queue</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTflush_queue.TCIFLUSH"><span class="constructor">TCIFLUSH</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTflush_queue.TCOFLUSH"><span class="constructor">TCOFLUSH</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTflush_queue.TCIOFLUSH"><span class="constructor">TCIOFLUSH</span></span></code></td>
</tr></table>
<pre><span id="VALtcflush"><span class="keyword">val</span> tcflush</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEflush_queue">flush_queue</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.tcflush</code><br>
</div>
<pre><span id="TYPEflow_action"><span class="keyword">type</span> <code class="type"></code>flow_action</span> = <code class="type">Unix.flow_action</code> = </pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTflow_action.TCOOFF"><span class="constructor">TCOOFF</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTflow_action.TCOON"><span class="constructor">TCOON</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTflow_action.TCIOFF"><span class="constructor">TCIOFF</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTflow_action.TCION"><span class="constructor">TCION</span></span></code></td>
</tr></table>
<pre><span id="VALtcflow"><span class="keyword">val</span> tcflow</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> <a href="Lwt_unix.html#TYPEflow_action">flow_action</a> -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wrapper for <code class="code"><span class="constructor">Unix</span>.tcflow</code><br>
</div>
<br>
<h6 id="6_Lowlevelinteraction">Low-level interaction</h6><br>
<pre><span id="EXCEPTIONRetry"><span class="keyword">exception</span> Retry</span></pre>
<div class="info ">
If an action raises <a href="Lwt_unix.html#EXCEPTIONRetry"><code class="code"><span class="constructor">Lwt_unix</span>.<span class="constructor">Retry</span></code></a>, it will be requeued until the <b> file descriptor</b> becomes readable/writable again.<br>
</div>
<pre><span id="EXCEPTIONRetry_read"><span class="keyword">exception</span> Retry_read</span></pre>
<div class="info ">
If an action raises <a href="Lwt_unix.html#EXCEPTIONRetry_read"><code class="code"><span class="constructor">Lwt_unix</span>.<span class="constructor">Retry_read</span></code></a>, it will be requeued until the
<b>file descriptor</b> becomes readable.<br>
</div>
<pre><span id="EXCEPTIONRetry_write"><span class="keyword">exception</span> Retry_write</span></pre>
<div class="info ">
If an action raises <a href="Lwt_unix.html#EXCEPTIONRetry_read"><code class="code"><span class="constructor">Lwt_unix</span>.<span class="constructor">Retry_read</span></code></a>, it will be requeued until the
<b>file descriptor</b> becomes writables.<br>
</div>
<pre><code><span id="TYPEio_event"><span class="keyword">type</span> <code class="type"></code>io_event</span> = </code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTio_event.Read"><span class="constructor">Read</span></span></code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code><span class="keyword">|</span></code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTio_event.Write"><span class="constructor">Write</span></span></code></td>
</tr></table>
<pre><span id="VALwrap_syscall"><span class="keyword">val</span> wrap_syscall</span> : <code class="type"><a href="Lwt_unix.html#TYPEio_event">io_event</a> -> <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> (unit -> 'a) -> 'a <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">wrap_syscall set fd action</code> wrap an action on a <b>file
descriptor</b>. It tries to execture action, and if it can not be
performed immediately without blocking, it is registered for
latter.
<p>
In the latter case, if the thread is canceled, <code class="code">action</code> is
removed from <code class="code">set</code>.<br>
</div>
<pre><span id="VALcheck_descriptor"><span class="keyword">val</span> check_descriptor</span> : <code class="type"><a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> unit</code></pre><div class="info ">
<code class="code">check_descriptor fd</code> raise an exception if <code class="code">fd</code> is not in the
state <code class="code"><span class="constructor">Open</span></code><br>
</div>
<pre><span id="VALregister_action"><span class="keyword">val</span> register_action</span> : <code class="type"><a href="Lwt_unix.html#TYPEio_event">io_event</a> -> <a href="Lwt_unix.html#TYPEfile_descr">file_descr</a> -> (unit -> 'a) -> 'a <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">register_action set fd action</code> registers <code class="code">action</code> on <code class="code">fd</code>. When
<code class="code">fd</code> becomes <code class="code">readable</code>/<code class="code">writable</code> <code class="code">action</code> is called.
<p>
Note:
<p>
<ul>
<li>you must call <code class="code">check_descriptor fd</code> before calling
<code class="code">register_action</code></li>
</ul>
<ul>
<li>you should prefer using <a href="Lwt_unix.html#VALwrap_syscall"><code class="code"><span class="constructor">Lwt_unix</span>.wrap_syscall</code></a></li>
</ul>
<br>
</div>
<pre><span id="TYPEjob"><span class="keyword">type</span> <code class="type">'a</code> job</span> </pre>
<div class="info ">
Type of job descriptions. A job description describe how to call
a C function and how to get its result. The C function may be
executed in another system thread.<br>
</div>
<pre><span id="VALexecute_job"><span class="keyword">val</span> execute_job</span> : <code class="type">?async_method:<a href="Lwt_unix.html#TYPEasync_method">async_method</a> -><br> job:'a <a href="Lwt_unix.html#TYPEjob">job</a> -><br> result:('a <a href="Lwt_unix.html#TYPEjob">job</a> -> 'b) -> free:('a <a href="Lwt_unix.html#TYPEjob">job</a> -> unit) -> 'b <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
This is the old and deprecated way of running a job. Use
<a href="Lwt_unix.html#VALrun_job"><code class="code"><span class="constructor">Lwt_unix</span>.run_job</code></a> in new code.<br>
</div>
<pre><span id="VALrun_job"><span class="keyword">val</span> run_job</span> : <code class="type">?async_method:<a href="Lwt_unix.html#TYPEasync_method">async_method</a> -> 'a <a href="Lwt_unix.html#TYPEjob">job</a> -> 'a <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
<code class="code">run_job ?async_method job</code> starts <code class="code">job</code> and wait for its
termination.
<p>
The async method is choosen follow:<ul>
<li>if the optional parameter <code class="code">async_method</code> is specified, it is
used,</li>
<li>otherwise if the local key <a href="Lwt_unix.html#VALasync_method_key"><code class="code"><span class="constructor">Lwt_unix</span>.async_method_key</code></a> is set in the
current thread, it is used,</li>
<li>otherwise the default method (returned by
<a href="Lwt_unix.html#VALdefault_async_method"><code class="code"><span class="constructor">Lwt_unix</span>.default_async_method</code></a>) is used.</li>
</ul>
If the method is <code class="code"><span class="constructor">Async_none</span></code> then the job is run synchronously
and may block the current system thread, thus blocking all Lwt
threads.
<p>
If the method is <code class="code"><span class="constructor">Async_detach</span></code> then the job is run in another
system thread, unless the the maximum number of worker threads
has been reached (as given by <a href="Lwt_unix.html#VALpool_size"><code class="code"><span class="constructor">Lwt_unix</span>.pool_size</code></a>).
<p>
If the method is <code class="code"><span class="constructor">Async_switch</span></code> then the job is run
synchronously and if it blocks, execution will continue in
another system thread (unless the limit is reached).<br>
</div>
<pre><span id="VALabort_jobs"><span class="keyword">val</span> abort_jobs</span> : <code class="type">exn -> unit</code></pre><div class="info ">
<code class="code">abort_jobs exn</code> make all pending jobs to fail with exn. Note
that this does not abort the real job (i.e. the C function
executing it), just the lwt thread for it.<br>
</div>
<pre><span id="VALcancel_jobs"><span class="keyword">val</span> cancel_jobs</span> : <code class="type">unit -> unit</code></pre><div class="info ">
<code class="code">cancel_jobs ()</code> is the same as <code class="code">abort_jobs <span class="constructor">Lwt</span>.<span class="constructor">Canceled</span></code>.<br>
</div>
<pre><span id="VALwait_for_jobs"><span class="keyword">val</span> wait_for_jobs</span> : <code class="type">unit -> unit <a href="Lwt.html#TYPEt">Lwt.t</a></code></pre><div class="info ">
Wait for all pending jobs to terminate.<br>
</div>
<br>
<h6 id="6_Notifications">Notifications</h6><br>
<br>
Lwt internally use a pipe to send notification to the main
thread. The following functions allow to use this pipe.<br>
<pre><span id="VALmake_notification"><span class="keyword">val</span> make_notification</span> : <code class="type">?once:bool -> (unit -> unit) -> int</code></pre><div class="info ">
<code class="code">new_notifier ?once f</code> registers a new notifier. It returns the
id of the notifier. Each time a notification with this id is
received, <code class="code">f</code> is called.
<p>
if <code class="code">once</code> is specified, then the notification is stopped after
the first time it is received. It defaults to <code class="code"><span class="keyword">false</span></code>.<br>
</div>
<pre><span id="VALsend_notification"><span class="keyword">val</span> send_notification</span> : <code class="type">int -> unit</code></pre><div class="info ">
<code class="code">send_notification id</code> sends a notification.
<p>
This function is thread-safe.<br>
</div>
<pre><span id="VALstop_notification"><span class="keyword">val</span> stop_notification</span> : <code class="type">int -> unit</code></pre><div class="info ">
Stop the given notification. Note that you should not reuse the
id after the notification has been stopped, the result is
unspecified if you do so.<br>
</div>
<pre><span id="VALcall_notification"><span class="keyword">val</span> call_notification</span> : <code class="type">int -> unit</code></pre><div class="info ">
Call the handler associated to the given notification. Note that
if the notification was defined with <code class="code">once = <span class="keyword">true</span></code> it is removed.<br>
</div>
<pre><span id="VALset_notification"><span class="keyword">val</span> set_notification</span> : <code class="type">int -> (unit -> unit) -> unit</code></pre><div class="info ">
<code class="code">set_notification id f</code> replace the function associated to the
notification by <code class="code">f</code>. It raises <code class="code"><span class="constructor">Not_found</span></code> if the given
notification is not found.<br>
</div>
<br>
<h6 id="6_Systemthreadspool">System threads pool</h6><br>
<br>
If the program is using the async method <code class="code"><span class="constructor">Async_detach</span></code> or
<code class="code"><span class="constructor">Async_switch</span></code>, Lwt will launch system threads to execute
blocking system calls asynchronously.<br>
<pre><span id="VALpool_size"><span class="keyword">val</span> pool_size</span> : <code class="type">unit -> int</code></pre><div class="info ">
Maximum number of system threads that can be started. If this
limit is reached, jobs will be executed synchronously.<br>
</div>
<pre><span id="VALset_pool_size"><span class="keyword">val</span> set_pool_size</span> : <code class="type">int -> unit</code></pre><div class="info ">
Change the size of the pool.<br>
</div>
<pre><span id="VALthread_count"><span class="keyword">val</span> thread_count</span> : <code class="type">unit -> int</code></pre><div class="info ">
The number of system threads running (excluding this one).<br>
</div>
<pre><span id="VALthread_waiting_count"><span class="keyword">val</span> thread_waiting_count</span> : <code class="type">unit -> int</code></pre><div class="info ">
The number threads waiting for a job.<br>
</div>
<br>
<h6 id="6_CPUs">CPUs</h6><br>
<pre><span id="VALget_cpu"><span class="keyword">val</span> get_cpu</span> : <code class="type">unit -> int</code></pre><div class="info ">
<code class="code">get_cpu ()</code> returns the number of the CPU the current thread is
running on.<br>
</div>
<pre><span id="VALget_affinity"><span class="keyword">val</span> get_affinity</span> : <code class="type">?pid:int -> unit -> int list</code></pre><div class="info ">
<code class="code">get_affinity ?pid ()</code> returns the list of CPUs the process with
pid <code class="code">pid</code> is allowed to run on. If <code class="code">pid</code> is not specified then
the affinity of the current process is returned.<br>
</div>
<pre><span id="VALset_affinity"><span class="keyword">val</span> set_affinity</span> : <code class="type">?pid:int -> int list -> unit</code></pre><div class="info ">
<code class="code">set_affinity ?pid cpus</code> sets the list of CPUs the given process
is allowed to run on.<br>
</div>
</body></html>
|