Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # get-port [![Build Status](https://travis-ci.org/sindresorhus/get-port.svg?branch=master)](https://travis-ci.org/sindresorhus/get-port)
  2. > Get an available [TCP port](https://en.wikipedia.org/wiki/Port_(computer_networking))
  3. ## Install
  4. ```
  5. $ npm install get-port
  6. ```
  7. ## Usage
  8. ```js
  9. const getPort = require('get-port');
  10. (async () => {
  11. console.log(await getPort());
  12. //=> 51402
  13. })();
  14. ```
  15. Pass in a preferred port:
  16. ```js
  17. (async () => {
  18. console.log(await getPort({port: 3000}));
  19. // Will use 3000 if available, otherwise fall back to a random port
  20. })();
  21. ```
  22. Pass in an array of preferred ports:
  23. ```js
  24. (async () => {
  25. console.log(await getPort({port: [3000, 3001, 3002]}));
  26. // Will use any element in the preferred ports array if available, otherwise fall back to a random port
  27. })();
  28. ```
  29. Use the `makeRange()` helper in case you need a port in a certain range:
  30. ```js
  31. (async () => {
  32. console.log(await getPort({port: getPort.makeRange(3000, 3100)}));
  33. // Will use any port from 3000 to 3100, otherwise fall back to a random port
  34. })();
  35. ```
  36. ## API
  37. ### getPort(options?)
  38. Returns a `Promise` for a port number.
  39. #### options
  40. Type: `object`
  41. ##### port
  42. Type: `number | Iterable<number>`
  43. A preferred port or an iterable of preferred ports to use.
  44. ##### host
  45. Type: `string`
  46. The host on which port resolution should be performed. Can be either an IPv4 or IPv6 address.
  47. ### getPort.makeRange(from, to)
  48. Make a range of ports `from`...`to`.
  49. Returns an `Iterable` for ports in the given range.
  50. #### from
  51. Type: `number`
  52. First port of the range. Must be in the range `1024`...`65535`.
  53. #### to
  54. Type: `number`
  55. Last port of the range. Must be in the range `1024`...`65535` and must be greater than `from`.
  56. ## Beware
  57. There is a very tiny chance of a race condition if another process starts using the same port number as you in between the time you get the port number and you actually start using it.
  58. Race conditions in the same process are mitigated against by using a lightweight locking mechanism where a port will be held for a minimum of 15 seconds and a maximum of 30 seconds before being released again.
  59. ## Related
  60. - [get-port-cli](https://github.com/sindresorhus/get-port-cli) - CLI for this module
  61. ---
  62. <div align="center">
  63. <b>
  64. <a href="https://tidelift.com/subscription/pkg/npm-get-port?utm_source=npm-get-port&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
  65. </b>
  66. <br>
  67. <sub>
  68. Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
  69. </sub>
  70. </div>