Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

close.c
Go to the documentation of this file.
1 /* Ignore ECONNRESET of FreeBSD */
2 #include "ruby/missing.h"
3 #include <errno.h>
4 #include <unistd.h>
5 #include <sys/types.h>
6 #include <sys/socket.h>
7
8 #undef getpeername
9 int
10 ruby_getpeername(int s, struct sockaddr * name,
11 socklen_t * namelen)
12 {
13 int err = errno;
14 errno = 0;
15 s = getpeername(s, name, namelen);
16 if (errno == ECONNRESET) {
17 errno = 0;
18 s = 0;
19 }
20 else if (errno == 0)
21 errno = err;
22 return s;
23 }
24
25 #undef getsockname
26 int
27 ruby_getsockname(int s, struct sockaddr * name,
28 socklen_t * namelen)
29 {
30 int err = errno;
31 errno = 0;
32 s = getsockname(s, name, namelen);
33 if (errno == ECONNRESET) {
34 errno = 0;
35 s = 0;
36 }
37 else if (errno == 0)
38 errno = err;
39 return s;
40 }
41
42 #undef shutdown
43 int
44 ruby_shutdown(int s, int how)
45 {
46 int err = errno;
47 errno = 0;
48 s = shutdown(s, how);
49 if (errno == ECONNRESET) {
50 errno = 0;
51 s = 0;
52 }
53 else if (errno == 0)
54 errno = err;
55 return s;
56 }
57
58 #undef close
59 int
60 ruby_close(int s)
61 {
62 int err = errno;
63 errno = 0;
64 s = close(s);
65 if (errno == ECONNRESET) {
66 errno = 0;
67 s = 0;
68 }
69 else if (errno == 0)
70 errno = err;
71 return s;
72 }
ruby_getpeername
int ruby_getpeername(int s, struct sockaddr *name, socklen_t *namelen)
Definition: close.c:10
ruby_getsockname
int ruby_getsockname(int s, struct sockaddr *name, socklen_t *namelen)
Definition: close.c:27
missing.h
ECONNRESET
#define ECONNRESET
Definition: win32.h:531
unistd.h
err
int err
Definition: win32.c:87
errno
int errno
s
register char * s
Definition: os2.c:56
shutdown
#define shutdown(a, b)
Definition: io.c:562
ruby_shutdown
int ruby_shutdown(int s, int how)
Definition: close.c:44
ruby_close
int ruby_close(int s)
Definition: close.c:60
name
const char * name
Definition: nkf.c:208