12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #ifndef NET_UTILS_MD_H
27 #define NET_UTILS_MD_H
28
29 #include <netdb.h>
30 #include <poll.h>
31 #include <sys/socket.h>
32
33 /************************************************************************
34 * Macros and constants
35 */
36
37 #define NET_NSEC_PER_MSEC 1000000
38 #define NET_NSEC_PER_SEC 1000000000
39 #define NET_NSEC_PER_USEC 1000
40
41 /* in case NI_MAXHOST is not defined in netdb.h */
42 #ifndef NI_MAXHOST
43 #define NI_MAXHOST 1025
44 #endif
45
46 /* Defines SO_REUSEPORT */
47 #ifndef SO_REUSEPORT
48 #ifdef __linux__
49 #define SO_REUSEPORT 15
50 #elif defined(__solaris__)
51 #define SO_REUSEPORT 0x100e
54 #else
55 #define SO_REUSEPORT 0
56 #endif
57 #endif
58
59 /*
60 * On 64-bit JDKs we use a much larger stack and heap buffer.
61 */
62 #ifdef _LP64
63 #define MAX_BUFFER_LEN 65536
64 #define MAX_HEAP_BUFFER_LEN 131072
65 #else
66 #define MAX_BUFFER_LEN 8192
67 #define MAX_HEAP_BUFFER_LEN 65536
68 #endif
69
70 typedef union {
71 struct sockaddr sa;
72 struct sockaddr_in sa4;
73 struct sockaddr_in6 sa6;
74 } SOCKETADDRESS;
75
76 /************************************************************************
77 * Functions
78 */
79
80 int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp);
81 int NET_Read(int s, void* buf, size_t len);
82 int NET_NonBlockingRead(int s, void* buf, size_t len);
83 int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
84 struct sockaddr *from, socklen_t *fromlen);
85 int NET_ReadV(int s, const struct iovec * vector, int count);
86 int NET_Send(int s, void *msg, int len, unsigned int flags);
87 int NET_SendTo(int s, const void *msg, int len, unsigned int
88 flags, const struct sockaddr *to, int tolen);
89 int NET_Connect(int s, struct sockaddr *addr, int addrlen);
90 int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen);
91 int NET_SocketClose(int s);
92 int NET_Dup2(int oldfd, int newfd);
93 int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout);
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #ifndef NET_UTILS_MD_H
27 #define NET_UTILS_MD_H
28
29 #include <netdb.h>
30 #include <poll.h>
31 #include <sys/socket.h>
32 #include <sys/un.h>
33
34 /************************************************************************
35 * Macros and constants
36 */
37
38 #define NET_NSEC_PER_MSEC 1000000
39 #define NET_NSEC_PER_SEC 1000000000
40 #define NET_NSEC_PER_USEC 1000
41
42 /* in case NI_MAXHOST is not defined in netdb.h */
43 #ifndef NI_MAXHOST
44 #define NI_MAXHOST 1025
45 #endif
46
47 /* Defines SO_REUSEPORT */
48 #ifndef SO_REUSEPORT
49 #ifdef __linux__
50 #define SO_REUSEPORT 15
51 #elif defined(__solaris__)
52 #define SO_REUSEPORT 0x100e
55 #else
56 #define SO_REUSEPORT 0
57 #endif
58 #endif
59
60 /*
61 * On 64-bit JDKs we use a much larger stack and heap buffer.
62 */
63 #ifdef _LP64
64 #define MAX_BUFFER_LEN 65536
65 #define MAX_HEAP_BUFFER_LEN 131072
66 #else
67 #define MAX_BUFFER_LEN 8192
68 #define MAX_HEAP_BUFFER_LEN 65536
69 #endif
70
71 typedef union {
72 struct sockaddr sa;
73 struct sockaddr_in sa4;
74 struct sockaddr_in6 sa6;
75 struct sockaddr_un sau;
76 } SOCKETADDRESS;
77
78 /************************************************************************
79 * Functions
80 */
81
82 int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp);
83 int NET_Read(int s, void* buf, size_t len);
84 int NET_NonBlockingRead(int s, void* buf, size_t len);
85 int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
86 struct sockaddr *from, socklen_t *fromlen);
87 int NET_ReadV(int s, const struct iovec * vector, int count);
88 int NET_Send(int s, void *msg, int len, unsigned int flags);
89 int NET_SendTo(int s, const void *msg, int len, unsigned int
90 flags, const struct sockaddr *to, int tolen);
91 int NET_Connect(int s, struct sockaddr *addr, int addrlen);
92 int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen);
93 int NET_SocketClose(int s);
94 int NET_Dup2(int oldfd, int newfd);
95 int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout);
|