5 GetSocketBufSize(int UNUSED(sockfd
), size_t *const rsize
, size_t *const ssize
)
7 LIBSIO_USE_VAR(sockfd
);
13 } /* GetSocketBufSize */
16 GetSocketBufSize(int sockfd
, size_t *const rsize
, size_t *const ssize
)
24 optsize
= sizeof(opt
);
25 rc
= getsockopt(sockfd
, SOL_SOCKET
, SO_SNDBUF
, (char *) &opt
, &optsize
);
27 *ssize
= (size_t) opt
;
33 optsize
= sizeof(opt
);
34 rc
= getsockopt(sockfd
, SOL_SOCKET
, SO_RCVBUF
, (char *) &opt
, &optsize
);
36 *rsize
= (size_t) opt
;
41 } /* GetSocketBufSize */
49 SetSocketBufSize(int UNUSED(sockfd
), size_t UNUSED(rsize
), size_t UNUSED(ssize
))
51 LIBSIO_USE_VAR(sockfd
);
52 LIBSIO_USE_VAR(rsize
);
53 LIBSIO_USE_VAR(ssize
);
55 } /* SetSocketBufSize */
58 SetSocketBufSize(int sockfd
, size_t rsize
, size_t ssize
)
66 optsize
= sizeof(opt
);
67 rc
= setsockopt(sockfd
, SOL_SOCKET
, SO_SNDBUF
, (const char *) &opt
, optsize
);
73 optsize
= sizeof(opt
);
74 rc
= setsockopt(sockfd
, SOL_SOCKET
, SO_RCVBUF
, (const char *) &opt
, optsize
);
79 } /* SetSocketBufSize */
87 GetSocketNagleAlgorithm(const int UNUSED(fd
))
91 } /* GetSocketNagleAlgorithm */
94 GetSocketNagleAlgorithm(const int fd
)
100 optsize
= (int) sizeof(opt
);
101 if (getsockopt(fd
, IPPROTO_TCP
, TCP_NODELAY
, (char *) &opt
, &optsize
) < 0)
104 } /* GetSocketNagleAlgorithm */
105 #endif /* TCP_NODELAY */
113 SetSocketNagleAlgorithm(const int UNUSED(fd
), const int UNUSED(onoff
))
116 LIBSIO_USE_VAR(onoff
);
118 } /* SetSocketNagleAlgorithm */
121 SetSocketNagleAlgorithm(const int fd
, const int onoff
)
127 optsize
= (int) sizeof(opt
);
128 return (setsockopt(fd
, IPPROTO_TCP
, TCP_NODELAY
, (char *) &opt
, optsize
));
129 } /* SetSocketNagleAlgorithm */
130 #endif /* TCP_NODELAY */
136 GetSocketLinger(const int UNUSED(fd
), int *const UNUSED(lingertime
))
139 LIBSIO_USE_VAR(lingertime
);
141 } /* GetSocketLinger */
144 GetSocketLinger(const int fd
, int *const lingertime
)
149 optsize
= (int) sizeof(opt
);
152 if (getsockopt(fd
, SOL_SOCKET
, SO_LINGER
, (char *) &opt
, &optsize
) < 0)
154 if (lingertime
!= NULL
)
155 *lingertime
= opt
.l_linger
;
156 return (opt
.l_onoff
);
157 } /* GetSocketLinger */
158 #endif /* SO_LINGER */
164 SetSocketLinger(const int UNUSED(fd
), const int UNUSED(l_onoff
), const int UNUSED(l_linger
))
167 LIBSIO_USE_VAR(l_onoff
);
168 LIBSIO_USE_VAR(l_linger
);
170 } /* SetSocketLinger */
173 SetSocketLinger(const int fd
, const int l_onoff
, const int l_linger
)
180 * Structure used for manipulating linger option.
183 * close(2) returns immediately; any buffered data is sent later
187 * if l_linger == 0, close(2) returns after discarding any unsent data
188 * if l_linger != 0, close(2) does not return until buffered data is sent
192 int l_onoff
; /* 0 = do not wait to send data */
193 /* non-0 = see l_linger */
194 int l_linger
; /* 0 = discard unsent data */
195 /* non-0 = wait to send data */
198 opt
.l_onoff
= l_onoff
;
199 opt
.l_linger
= l_linger
;
200 optsize
= (int) sizeof(opt
);
201 return (setsockopt(fd
, SOL_SOCKET
, SO_LINGER
, (char *) &opt
, optsize
));
202 } /* SetSocketLinger */
203 #endif /* SO_LINGER */