-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Expand file tree
/
Copy pathos.md
More file actions
1177 lines (1084 loc) Β· 29.7 KB
/
os.md
File metadata and controls
1177 lines (1084 loc) Β· 29.7 KB
Edit and raw actions
OlderNewer
Β
1
# OS
2
3
> Stability: 2 - Stable
4
5
The `os` module provides a number of operating system-related utility methods.
6
It can be accessed using:
7
8
```js
9
const os = require('os');
10
```
11
12
## os.EOL
13
<!-- YAML
14
added: v0.7.8
15
-->
16
17
* {string}
18
19
A string constant defining the operating system-specific end-of-line marker:
20
21
* `\n` on POSIX
22
* `\r\n` on Windows
23
24
## os.arch()
25
<!-- YAML
26
added: v0.5.0
27
-->
28
29
* Returns: {string}
30
31
The `os.arch()` method returns a string identifying the operating system CPU
32
architecture *for which the Node.js binary was compiled*.
33
34
The current possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,
35
`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, `'x32'`, `'x64'`, and
36
`'x86'`.
37
38
Equivalent to [`process.arch`][].
39
40
## os.constants
41
<!-- YAML
42
added: v6.3.0
43
-->
44
45
* {Object}
46
47
Returns an object containing commonly used operating system specific constants
48
for error codes, process signals, and so on. The specific constants currently
49
defined are described in [OS Constants][].
50
51
## os.cpus()
52
<!-- YAML
53
added: v0.3.3
54
-->
55
56
* Returns: {Array}
57
58
The `os.cpus()` method returns an array of objects containing information about
59
each CPU/core installed.
60
61
The properties included on each object include:
62
63
* `model` {string}
64
* `speed` {number} (in MHz)
65
* `times` {Object}
66
* `user` {number} The number of milliseconds the CPU has spent in user mode.
67
* `nice` {number} The number of milliseconds the CPU has spent in nice mode.
68
* `sys` {number} The number of milliseconds the CPU has spent in sys mode.
69
* `idle` {number} The number of milliseconds the CPU has spent in idle mode.
70
* `irq` {number} The number of milliseconds the CPU has spent in irq mode.
71
72
For example:
73
74
```js
75
[
76
{
77
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
78
speed: 2926,
79
times: {
80
user: 252020,
81
nice: 0,
82
sys: 30340,
83
idle: 1070356870,
84
irq: 0
85
}
86
},
87
{
88
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
89
speed: 2926,
90
times: {
91
user: 306960,
92
nice: 0,
93
sys: 26980,
94
idle: 1071569080,
95
irq: 0
96
}
97
},
98
{
99
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
100
speed: 2926,
101
times: {
102
user: 248450,
103
nice: 0,
104
sys: 21750,
105
idle: 1070919370,
106
irq: 0
107
}
108
},
109
{
110
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
111
speed: 2926,
112
times: {
113
user: 256880,
114
nice: 0,
115
sys: 19430,
116
idle: 1070905480,
117
irq: 20
118
}
119
},
120
{
121
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
122
speed: 2926,
123
times: {
124
user: 511580,
125
nice: 20,
126
sys: 40900,
127
idle: 1070842510,
128
irq: 0
129
}
130
},
131
{
132
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
133
speed: 2926,
134
times: {
135
user: 291660,
136
nice: 0,
137
sys: 34360,
138
idle: 1070888000,
139
irq: 10
140
}
141
},
142
{
143
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
144
speed: 2926,
145
times: {
146
user: 308260,
147
nice: 0,
148
sys: 55410,
149
idle: 1071129970,
150
irq: 880
151
}
152
},
153
{
154
model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
155
speed: 2926,
156
times: {
157
user: 266450,
158
nice: 1480,
159
sys: 34920,
160
idle: 1072572010,
161
irq: 30
162
}
163
}
164
]
165
```
166
167
*Note*: Because `nice` values are UNIX-specific, on Windows the `nice` values of
168
all processors are always 0.
169
170
## os.endianness()
171
<!-- YAML
172
added: v0.9.4
173
-->
174
175
* Returns: {string}
176
177
The `os.endianness()` method returns a string identifying the endianness of the
178
CPU *for which the Node.js binary was compiled*.
179
180
Possible values are:
181
182
* `'BE'` for big endian
183
* `'LE'` for little endian.
184
185
## os.freemem()
186
<!-- YAML
187
added: v0.3.3
188
-->
189
190
* Returns: {integer}
191
192
The `os.freemem()` method returns the amount of free system memory in bytes as
193
an integer.
194
195
## os.homedir()
196
<!-- YAML
197
added: v2.3.0
198
-->
199
200
* Returns: {string}
201
202
The `os.homedir()` method returns the home directory of the current user as a
203
string.
204
205
## os.hostname()
206
<!-- YAML
207
added: v0.3.3
208
-->
209
210
* Returns: {string}
211
212
The `os.hostname()` method returns the hostname of the operating system as a
213
string.
214
215
## os.loadavg()
216
<!-- YAML
217
added: v0.3.3
218
-->
219
220
* Returns: {Array}
221
222
The `os.loadavg()` method returns an array containing the 1, 5, and 15 minute
223
load averages.
224
225
The load average is a measure of system activity, calculated by the operating
226
system and expressed as a fractional number. As a rule of thumb, the load
227
average should ideally be less than the number of logical CPUs in the system.
228
229
The load average is a UNIX-specific concept with no real equivalent on
230
Windows platforms. On Windows, the return value is always `[0, 0, 0]`.
231
232
## os.networkInterfaces()
233
<!-- YAML
234
added: v0.6.0
235
-->
236
237
* Returns: {Object}
238
239
The `os.networkInterfaces()` method returns an object containing only network
240
interfaces that have been assigned a network address.
241
242
Each key on the returned object identifies a network interface. The associated
243
value is an array of objects that each describe an assigned network address.
244
245
The properties available on the assigned network address object include:
246
247
* `address` {string} The assigned IPv4 or IPv6 address
248
* `netmask` {string} The IPv4 or IPv6 network mask
249
* `family` {string} Either `IPv4` or `IPv6`
250
* `mac` {string} The MAC address of the network interface
251
* `internal` {boolean} `true` if the network interface is a loopback or
252
similar interface that is not remotely accessible; otherwise `false`
253
* `scopeid` {number} The numeric IPv6 scope ID (only specified when `family`
254
is `IPv6`)
255
256
```js
257
{
258
lo: [
259
{
260
address: '127.0.0.1',
261
netmask: '255.0.0.0',
262
family: 'IPv4',
263
mac: '00:00:00:00:00:00',
264
internal: true
265
},
266
{
267
address: '::1',
268
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
269
family: 'IPv6',
270
mac: '00:00:00:00:00:00',
271
internal: true
272
}
273
],
274
eth0: [
275
{
276
address: '192.168.1.108',
277
netmask: '255.255.255.0',
278
family: 'IPv4',
279
mac: '01:02:03:0a:0b:0c',
280
internal: false
281
},
282
{
283
address: 'fe80::a00:27ff:fe4e:66a1',
284
netmask: 'ffff:ffff:ffff:ffff::',
285
family: 'IPv6',
286
mac: '01:02:03:0a:0b:0c',
287
internal: false
288
}
289
]
290
}
291
```
292
293
## os.platform()
294
<!-- YAML
295
added: v0.5.0
296
-->
297
298
* Returns: {string}
299
300
The `os.platform()` method returns a string identifying the operating system
301
platform as set during compile time of Node.js.
302
303
Currently possible values are:
304
305
* `'aix'`
306
* `'darwin'`
307
* `'freebsd'`
308
* `'linux'`
309
* `'openbsd'`
310
* `'sunos'`
311
* `'win32'`
312
313
Equivalent to [`process.platform`][].
314
315
*Note*: The value `'android'` may also be returned if the Node.js is built on
316
the Android operating system. However, Android support in Node.js is considered
317
to be experimental at this time.
318
319
## os.release()
320
<!-- YAML
321
added: v0.3.3
322
-->
323
324
* Returns: {string}
325
326
The `os.release()` method returns a string identifying the operating system
327
release.
328
329
*Note*: On POSIX systems, the operating system release is determined by calling
330
uname(3). On Windows, `GetVersionExW()` is used. Please see
331
https://en.wikipedia.org/wiki/Uname#Examples for more information.
332
333
## os.tmpdir()
334
<!-- YAML
335
added: v0.9.9
336
changes:
337
- version: v2.0.0
338
pr-url: https://github.com/nodejs/node/pull/747
339
description: This function is now cross-platform consistent and no longer
340
returns a path with a trailing slash on any platform
341
-->
342
343
* Returns: {string}
344
345
The `os.tmpdir()` method returns a string specifying the operating system's
346
default directory for temporary files.
347
348
## os.totalmem()
349
<!-- YAML
350
added: v0.3.3
351
-->
352
353
* Returns: {integer}
354
355
The `os.totalmem()` method returns the total amount of system memory in bytes
356
as an integer.
357
358
## os.type()
359
<!-- YAML
360
added: v0.3.3
361
-->
362
363
* Returns: {string}
364
365
The `os.type()` method returns a string identifying the operating system name
366
as returned by uname(3). For example `'Linux'` on Linux, `'Darwin'` on macOS and
367
`'Windows_NT'` on Windows.
368
369
Please see https://en.wikipedia.org/wiki/Uname#Examples for additional
370
information about the output of running uname(3) on various operating systems.
371
372
## os.uptime()
373
<!-- YAML
374
added: v0.3.3
375
-->
376
377
* Returns: {integer}
378
379
The `os.uptime()` method returns the system uptime in number of seconds.
380
381
*Note*: Within Node.js' internals, this number is represented as a `double`.
382
However, fractional seconds are not returned and the value can typically be
383
treated as an integer.
384
385
## os.userInfo([options])
386
<!-- YAML
387
added: v6.0.0
388
-->
389
390
* `options` {Object}
391
* `encoding` {string} Character encoding used to interpret resulting strings.
392
If `encoding` is set to `'buffer'`, the `username`, `shell`, and `homedir`
393
values will be `Buffer` instances. (Default: 'utf8')
394
* Returns: {Object}
395
396
The `os.userInfo()` method returns information about the currently effective
397
user -- on POSIX platforms, this is typically a subset of the password file. The
398
returned object includes the `username`, `uid`, `gid`, `shell`, and `homedir`.
399
On Windows, the `uid` and `gid` fields are `-1`, and `shell` is `null`.
400
401
The value of `homedir` returned by `os.userInfo()` is provided by the operating
402
system. This differs from the result of `os.homedir()`, which queries several
403
environment variables for the home directory before falling back to the
404
operating system response.
405
406
## OS Constants
407
408
The following constants are exported by `os.constants`. **Note:** Not all
409
constants will be available on every operating system.
410
411
### Signal Constants
412
<!-- YAML
413
changes:
414
- version: v5.11.0
415
pr-url: https://github.com/nodejs/node/pull/6093
416
description: Added support for `SIGINFO`.
417
-->
418
419
The following signal constants are exported by `os.constants.signals`:
420
421
<table>
422
<tr>
423
<th>Constant</th>
424
<th>Description</th>
425
</tr>
426
<tr>
427
<td><code>SIGHUP</code></td>
428
<td>Sent to indicate when a controlling terminal is closed or a parent
429
process exits.</td>
430
</tr>
431
<tr>
432
<td><code>SIGINT</code></td>
433
<td>Sent to indicate when a user wishes to interrupt a process
434
(`(Ctrl+C)`).</td>
435
</tr>
436
<tr>
437
<td><code>SIGQUIT</code></td>
438
<td>Sent to indicate when a user wishes to terminate a process and perform a
439
core dump.</td>
440
</tr>
441
<tr>
442
<td><code>SIGILL</code></td>
443
<td>Sent to a process to notify that it has attempted to perform an illegal,
444
malformed, unknown or privileged instruction.</td>
445
</tr>
446
<tr>
447
<td><code>SIGTRAP</code></td>
448
<td>Sent to a process when an exception has occurred.</td>
449
</tr>
450
<tr>
451
<td><code>SIGABRT</code></td>
452
<td>Sent to a process to request that it abort.</td>
453
</tr>
454
<tr>
455
<td><code>SIGIOT</code></td>
456
<td>Synonym for <code>SIGABRT</code></td>
457
</tr>
458
<tr>
459
<td><code>SIGBUS</code></td>
460
<td>Sent to a process to notify that it has caused a bus error.</td>
461
</tr>
462
<tr>
463
<td><code>SIGFPE</code></td>
464
<td>Sent to a process to notify that it has performed an illegal arithmetic
465
operation.</td>
466
</tr>
467
<tr>
468
<td><code>SIGKILL</code></td>
469
<td>Sent to a process to terminate it immediately.</td>
470
</tr>
471
<tr>
472
<td><code>SIGUSR1</code> <code>SIGUSR2</code></td>
473
<td>Sent to a process to identify user-defined conditions.</td>
474
</tr>
475
<tr>
476
<td><code>SIGSEGV</code></td>
477
<td>Sent to a process to notify of a segmentation fault.</td>
478
</tr>
479
<tr>
480
<td><code>SIGPIPE</code></td>
481
<td>Sent to a process when it has attempted to write to a disconnected
482
pipe.</td>
483
</tr>
484
<tr>
485
<td><code>SIGALRM</code></td>
486
<td>Sent to a process when a system timer elapses.</td>
487
</tr>
488
<tr>
489
<td><code>SIGTERM</code></td>
490
<td>Sent to a process to request termination.</td>
491
</tr>
492
<tr>
493
<td><code>SIGCHLD</code></td>
494
<td>Sent to a process when a child process terminates.</td>
495
</tr>
496
<tr>
497
<td><code>SIGSTKFLT</code></td>
498
<td>Sent to a process to indicate a stack fault on a coprocessor.</td>
499
</tr>
500
<tr>
501
<td><code>SIGCONT</code></td>
502
<td>Sent to instruct the operating system to continue a paused process.</td>
503
</tr>
504
<tr>
505
<td><code>SIGSTOP</code></td>
506
<td>Sent to instruct the operating system to halt a process.</td>
507
</tr>
508
<tr>
509
<td><code>SIGTSTP</code></td>
510
<td>Sent to a process to request it to stop.</td>
511
</tr>
512
<tr>
513
<td><code>SIGBREAK</code></td>
514
<td>Sent to indicate when a user wishes to interrupt a process.</td>
515
</tr>
516
<tr>
517
<td><code>SIGTTIN</code></td>
518
<td>Sent to a process when it reads from the TTY while in the
519
background.</td>
520
</tr>
521
<tr>
522
<td><code>SIGTTOU</code></td>
523
<td>Sent to a process when it writes to the TTY while in the
524
background.</td>
525
</tr>
526
<tr>
527
<td><code>SIGURG</code></td>
528
<td>Sent to a process when a socket has urgent data to read.</td>
529
</tr>
530
<tr>
531
<td><code>SIGXCPU</code></td>
532
<td>Sent to a process when it has exceeded its limit on CPU usage.</td>
533
</tr>
534
<tr>
535
<td><code>SIGXFSZ</code></td>
536
<td>Sent to a process when it grows a file larger than the maximum
537
allowed.</td>
538
</tr>
539
<tr>
540
<td><code>SIGVTALRM</code></td>
541
<td>Sent to a process when a virtual timer has elapsed.</td>
542
</tr>
543
<tr>
544
<td><code>SIGPROF</code></td>
545
<td>Sent to a process when a system timer has elapsed.</td>
546
</tr>
547
<tr>
548
<td><code>SIGWINCH</code></td>
549
<td>Sent to a process when the controlling terminal has changed its
550
size.</td>
551
</tr>
552
<tr>
553
<td><code>SIGIO</code></td>
554
<td>Sent to a process when I/O is available.</td>
555
</tr>
556
<tr>
557
<td><code>SIGPOLL</code></td>
558
<td>Synonym for <code>SIGIO</code></td>
559
</tr>
560
<tr>
561
<td><code>SIGLOST</code></td>
562
<td>Sent to a process when a file lock has been lost.</td>
563
</tr>
564
<tr>
565
<td><code>SIGPWR</code></td>
566
<td>Sent to a process to notify of a power failure.</td>
567
</tr>
568
<tr>
569
<td><code>SIGINFO</code></td>
570
<td>Synonym for <code>SIGPWR</code></td>
571
</tr>
572
<tr>
573
<td><code>SIGSYS</code></td>
574
<td>Sent to a process to notify of a bad argument.</td>
575
</tr>
576
<tr>
577
<td><code>SIGUNUSED</code></td>
578
<td>Synonym for <code>SIGSYS</code></td>
579
</tr>
580
</table>
581
582
### Error Constants
583
584
The following error constants are exported by `os.constants.errno`:
585
586
#### POSIX Error Constants
587
588
<table>
589
<tr>
590
<th>Constant</th>
591
<th>Description</th>
592
</tr>
593
<tr>
594
<td><code>E2BIG</code></td>
595
<td>Indicates that the list of arguments is longer than expected.</td>
596
</tr>
597
<tr>
598
<td><code>EACCES</code></td>
599
<td>Indicates that the operation did not have sufficient permissions.</td>
600
</tr>
601
<tr>
602
<td><code>EADDRINUSE</code></td>
603
<td>Indicates that the network address is already in use.</td>
604
</tr>
605
<tr>
606
<td><code>EADDRNOTAVAIL</code></td>
607
<td>Indicates that the network address is currently unavailable for
608
use.</td>
609
</tr>
610
<tr>
611
<td><code>EAFNOSUPPORT</code></td>
612
<td>Indicates that the network address family is not supported.</td>
613
</tr>
614
<tr>
615
<td><code>EAGAIN</code></td>
616
<td>Indicates that there is currently no data available and to try the
617
operation again later.</td>
618
</tr>
619
<tr>
620
<td><code>EALREADY</code></td>
621
<td>Indicates that the socket already has a pending connection in
622
progress.</td>
623
</tr>
624
<tr>
625
<td><code>EBADF</code></td>
626
<td>Indicates that a file descriptor is not valid.</td>
627
</tr>
628
<tr>
629
<td><code>EBADMSG</code></td>
630
<td>Indicates an invalid data message.</td>
631
</tr>
632
<tr>
633
<td><code>EBUSY</code></td>
634
<td>Indicates that a device or resource is busy.</td>
635
</tr>
636
<tr>
637
<td><code>ECANCELED</code></td>
638
<td>Indicates that an operation was canceled.</td>
639
</tr>
640
<tr>
641
<td><code>ECHILD</code></td>
642
<td>Indicates that there are no child processes.</td>
643
</tr>
644
<tr>
645
<td><code>ECONNABORTED</code></td>
646
<td>Indicates that the network connection has been aborted.</td>
647
</tr>
648
<tr>
649
<td><code>ECONNREFUSED</code></td>
650
<td>Indicates that the network connection has been refused.</td>
651
</tr>
652
<tr>
653
<td><code>ECONNRESET</code></td>
654
<td>Indicates that the network connection has been reset.</td>
655
</tr>
656
<tr>
657
<td><code>EDEADLK</code></td>
658
<td>Indicates that a resource deadlock has been avoided.</td>
659
</tr>
660
<tr>
661
<td><code>EDESTADDRREQ</code></td>
662
<td>Indicates that a destination address is required.</td>
663
</tr>
664
<tr>
665
<td><code>EDOM</code></td>
666
<td>Indicates that an argument is out of the domain of the function.</td>
667
</tr>
668
<tr>
669
<td><code>EDQUOT</code></td>
670
<td>Indicates that the disk quota has been exceeded.</td>
671
</tr>
672
<tr>
673
<td><code>EEXIST</code></td>
674
<td>Indicates that the file already exists.</td>
675
</tr>
676
<tr>
677
<td><code>EFAULT</code></td>
678
<td>Indicates an invalid pointer address.</td>
679
</tr>
680
<tr>
681
<td><code>EFBIG</code></td>
682
<td>Indicates that the file is too large.</td>
683
</tr>
684
<tr>
685
<td><code>EHOSTUNREACH</code></td>
686
<td>Indicates that the host is unreachable.</td>
687
</tr>
688
<tr>
689
<td><code>EIDRM</code></td>
690
<td>Indicates that the identifier has been removed.</td>
691
</tr>
692
<tr>
693
<td><code>EILSEQ</code></td>
694
<td>Indicates an illegal byte sequence.</td>
695
</tr>
696
<tr>
697
<td><code>EINPROGRESS</code></td>
698
<td>Indicates that an operation is already in progress.</td>
699
</tr>
700
<tr>
701
<td><code>EINTR</code></td>
702
<td>Indicates that a function call was interrupted.</td>
703
</tr>
704
<tr>
705
<td><code>EINVAL</code></td>
706
<td>Indicates that an invalid argument was provided.</td>
707
</tr>
708
<tr>
709
<td><code>EIO</code></td>
710
<td>Indicates an otherwise unspecified I/O error.</td>
711
</tr>
712
<tr>
713
<td><code>EISCONN</code></td>
714
<td>Indicates that the socket is connected.</td>
715
</tr>
716
<tr>
717
<td><code>EISDIR</code></td>
718
<td>Indicates that the path is a directory.</td>
719
</tr>
720
<tr>
721
<td><code>ELOOP</code></td>
722
<td>Indicates too many levels of symbolic links in a path.</td>
723
</tr>
724
<tr>
725
<td><code>EMFILE</code></td>
726
<td>Indicates that there are too many open files.</td>
727
</tr>
728
<tr>
729
<td><code>EMLINK</code></td>
730
<td>Indicates that there are too many hard links to a file.</td>
731
</tr>
732
<tr>
733
<td><code>EMSGSIZE</code></td>
734
<td>Indicates that the provided message is too long.</td>
735
</tr>
736
<tr>
737
<td><code>EMULTIHOP</code></td>
738
<td>Indicates that a multihop was attempted.</td>
739
</tr>
740
<tr>
741
<td><code>ENAMETOOLONG</code></td>
742
<td>Indicates that the filename is too long.</td>
743
</tr>
744
<tr>
745
<td><code>ENETDOWN</code></td>
746
<td>Indicates that the network is down.</td>
747
</tr>
748
<tr>
749
<td><code>ENETRESET</code></td>
750
<td>Indicates that the connection has been aborted by the network.</td>
751
</tr>
752
<tr>
753
<td><code>ENETUNREACH</code></td>
754
<td>Indicates that the network is unreachable.</td>
755
</tr>
756
<tr>
757
<td><code>ENFILE</code></td>
758
<td>Indicates too many open files in the system.</td>
759
</tr>
760
<tr>
761
<td><code>ENOBUFS</code></td>
762
<td>Indicates that no buffer space is available.</td>
763
</tr>
764
<tr>
765
<td><code>ENODATA</code></td>
766
<td>Indicates that no message is available on the stream head read
767
queue.</td>
768
</tr>
769
<tr>
770
<td><code>ENODEV</code></td>
771
<td>Indicates that there is no such device.</td>
772
</tr>
773
<tr>
774
<td><code>ENOENT</code></td>
775
<td>Indicates that there is no such file or directory.</td>
776
</tr>
777
<tr>
778
<td><code>ENOEXEC</code></td>
779
<td>Indicates an exec format error.</td>
780
</tr>
781
<tr>
782
<td><code>ENOLCK</code></td>
783
<td>Indicates that there are no locks available.</td>
784
</tr>
785
<tr>
786
<td><code>ENOLINK</code></td>
787
<td>Indications that a link has been severed.</td>
788
</tr>
789
<tr>
790
<td><code>ENOMEM</code></td>
791
<td>Indicates that there is not enough space.</td>
792
</tr>
793
<tr>
794
<td><code>ENOMSG</code></td>
795
<td>Indicates that there is no message of the desired type.</td>
796
</tr>
797
<tr>
798
<td><code>ENOPROTOOPT</code></td>
799
<td>Indicates that a given protocol is not available.</td>
800
</tr>
801
<tr>
802
<td><code>ENOSPC</code></td>
803
<td>Indicates that there is no space available on the device.</td>
804
</tr>
805
<tr>
806
<td><code>ENOSR</code></td>
807
<td>Indicates that there are no stream resources available.</td>
808
</tr>
809
<tr>
810
<td><code>ENOSTR</code></td>
811
<td>Indicates that a given resource is not a stream.</td>
812
</tr>
813
<tr>
814
<td><code>ENOSYS</code></td>
815
<td>Indicates that a function has not been implemented.</td>
816
</tr>
817
<tr>
818
<td><code>ENOTCONN</code></td>
819
<td>Indicates that the socket is not connected.</td>
820
</tr>
821
<tr>
822
<td><code>ENOTDIR</code></td>
823
<td>Indicates that the path is not a directory.</td>
824
</tr>
825
<tr>
826
<td><code>ENOTEMPTY</code></td>
827
<td>Indicates that the directory is not empty.</td>
828
</tr>
829
<tr>
830
<td><code>ENOTSOCK</code></td>
831
<td>Indicates that the given item is not a socket.</td>
832
</tr>
833
<tr>
834
<td><code>ENOTSUP</code></td>
835
<td>Indicates that a given operation is not supported.</td>
836
</tr>
837
<tr>
838
<td><code>ENOTTY</code></td>
839
<td>Indicates an inappropriate I/O control operation.</td>
840
</tr>
841
<tr>
842
<td><code>ENXIO</code></td>
843
<td>Indicates no such device or address.</td>
844
</tr>
845
<tr>
846
<td><code>EOPNOTSUPP</code></td>
847
<td>Indicates that an operation is not supported on the socket.
848
Note that while `ENOTSUP` and `EOPNOTSUPP` have the same value on Linux,
849
according to POSIX.1 these error values should be distinct.)</td>
850
</tr>
851
<tr>
852
<td><code>EOVERFLOW</code></td>
853
<td>Indicates that a value is too large to be stored in a given data
854
type.</td>
855
</tr>
856
<tr>
857
<td><code>EPERM</code></td>
858
<td>Indicates that the operation is not permitted.</td>
859
</tr>
860
<tr>
861
<td><code>EPIPE</code></td>
862
<td>Indicates a broken pipe.</td>
863
</tr>
864
<tr>
865
<td><code>EPROTO</code></td>
866
<td>Indicates a protocol error.</td>
867
</tr>
868
<tr>
869
<td><code>EPROTONOSUPPORT</code></td>
870
<td>Indicates that a protocol is not supported.</td>
871
</tr>
872
<tr>
873
<td><code>EPROTOTYPE</code></td>
874
<td>Indicates the wrong type of protocol for a socket.</td>
875
</tr>
876
<tr>
877
<td><code>ERANGE</code></td>
878
<td>Indicates that the results are too large.</td>
879
</tr>
880
<tr>
881
<td><code>EROFS</code></td>
882
<td>Indicates that the file system is read only.</td>
883
</tr>
884
<tr>
885
<td><code>ESPIPE</code></td>
886
<td>Indicates an invalid seek operation.</td>
887
</tr>
888
<tr>
889
<td><code>ESRCH</code></td>
890
<td>Indicates that there is no such process.</td>
891
</tr>
892
<tr>
893
<td><code>ESTALE</code></td>
894
<td>Indicates that the file handle is stale.</td>
895
</tr>
896
<tr>
897
<td><code>ETIME</code></td>
898
<td>Indicates an expired timer.</td>
899
</tr>
900
<tr>
901
<td><code>ETIMEDOUT</code></td>
902
<td>Indicates that the connection timed out.</td>
903
</tr>
904
<tr>
905
<td><code>ETXTBSY</code></td>
906
<td>Indicates that a text file is busy.</td>
907
</tr>
908
<tr>
909
<td><code>EWOULDBLOCK</code></td>
910
<td>Indicates that the operation would block.</td>
911
</tr>
912
<tr>
913
<td><code>EXDEV</code></td>
914
<td>Indicates an improper link.
915
</tr>
916
</table>
917
918
#### Windows Specific Error Constants
919
920
The following error codes are specific to the Windows operating system:
921
922
<table>
923
<tr>
924
<th>Constant</th>
925
<th>Description</th>
926
</tr>
927
<tr>
928
<td><code>WSAEINTR</code></td>
929
<td>Indicates an interrupted function call.</td>
930
</tr>
931
<tr>
932
<td><code>WSAEBADF</code></td>
933
<td>Indicates an invalid file handle.</td>
934
</tr>
935
<tr>
936
<td><code>WSAEACCES</code></td>
937
<td>Indicates insufficient permissions to complete the operation.</td>
938
</tr>
939
<tr>
940
<td><code>WSAEFAULT</code></td>
941
<td>Indicates an invalid pointer address.</td>
942
</tr>
943
<tr>
944
<td><code>WSAEINVAL</code></td>
945
<td>Indicates that an invalid argument was passed.</td>
946
</tr>
947
<tr>
948
<td><code>WSAEMFILE</code></td>
949
<td>Indicates that there are too many open files.</td>
950
</tr>
951
<tr>
952
<td><code>WSAEWOULDBLOCK</code></td>
953
<td>Indicates that a resource is temporarily unavailable.</td>
954
</tr>
955
<tr>
956
<td><code>WSAEINPROGRESS</code></td>
957
<td>Indicates that an operation is currently in progress.</td>
958
</tr>
959
<tr>
960
<td><code>WSAEALREADY</code></td>
961
<td>Indicates that an operation is already in progress.</td>
962
</tr>
963
<tr>
964
<td><code>WSAENOTSOCK</code></td>
965
<td>Indicates that the resource is not a socket.</td>
966
</tr>
967
<tr>
968
<td><code>WSAEDESTADDRREQ</code></td>
969
<td>Indicates that a destination address is required.</td>
970
</tr>
971
<tr>
972
<td><code>WSAEMSGSIZE</code></td>
973
<td>Indicates that the message size is too long.</td>
974
</tr>
975
<tr>
976
<td><code>WSAEPROTOTYPE</code></td>
977
<td>Indicates the wrong protocol type for the socket.</td>
978
</tr>
979
<tr>
980
<td><code>WSAENOPROTOOPT</code></td>
981
<td>Indicates a bad protocol option.</td>
982
</tr>
983
<tr>
984
<td><code>WSAEPROTONOSUPPORT</code></td>
985
<td>Indicates that the protocol is not supported.</td>
986
</tr>
987
<tr>
988
<td><code>WSAESOCKTNOSUPPORT</code></td>
989
<td>Indicates that the socket type is not supported.</td>
990
</tr>
991
<tr>
992
<td><code>WSAEOPNOTSUPP</code></td>
993
<td>Indicates that the operation is not supported.</td>
994
</tr>
995
<tr>
996
<td><code>WSAEPFNOSUPPORT</code></td>
997
<td>Indicates that the protocol family is not supported.</td>
998
</tr>
999
<tr>
1000
<td><code>WSAEAFNOSUPPORT</code></td>