1 17 18 package org.apache.tomcat.jni; 19 20 21 import java.nio.ByteBuffer ; 22 23 28 29 public class Socket { 30 31 32 public static final int SOCK_STREAM = 0; 33 public static final int SOCK_DGRAM = 1; 34 37 public static final int APR_SO_LINGER = 1; 38 public static final int APR_SO_KEEPALIVE = 2; 39 public static final int APR_SO_DEBUG = 4; 40 public static final int APR_SO_NONBLOCK = 8; 41 public static final int APR_SO_REUSEADDR = 16; 42 public static final int APR_SO_SNDBUF = 64; 43 public static final int APR_SO_RCVBUF = 128; 44 public static final int APR_SO_DISCONNECTED = 256; 45 46 public static final int APR_TCP_NODELAY = 512; 47 public static final int APR_TCP_NOPUSH = 1024; 48 52 public static final int APR_RESET_NODELAY = 2048; 53 60 public static final int APR_INCOMPLETE_READ = 4096; 61 63 public static final int APR_INCOMPLETE_WRITE = 8192; 64 66 public static final int APR_IPV6_V6ONLY = 16384; 67 69 public static final int APR_TCP_DEFER_ACCEPT = 32768; 70 71 74 public static final int APR_SHUTDOWN_READ = 0; 75 public static final int APR_SHUTDOWN_WRITE = 1; 76 public static final int APR_SHUTDOWN_READWRITE = 2; 77 78 public static final int APR_IPV4_ADDR_OK = 0x01; 79 public static final int APR_IPV6_ADDR_OK = 0x02; 80 81 86 public static final int APR_UNSPEC = 0; 87 public static final int APR_INET = 1; 88 public static final int APR_INET6 = 2; 89 90 public static final int APR_PROTO_TCP = 6; 91 public static final int APR_PROTO_UDP = 17; 92 public static final int APR_PROTO_SCTP = 132; 93 94 98 public static final int APR_LOCAL = 0; 99 public static final int APR_REMOTE = 1; 100 101 102 public static final int SOCKET_GET_POOL = 0; 103 public static final int SOCKET_GET_IMPL = 1; 104 public static final int SOCKET_GET_APRS = 2; 105 public static final int SOCKET_GET_TYPE = 3; 106 107 115 public static native long create(int family, int type, 116 int protocol, long cont) 117 throws Exception ; 118 119 120 133 public static native int shutdown(long thesocket, int how); 134 135 139 public static native int close(long thesocket); 140 141 145 public static native void destroy(long thesocket); 146 147 154 public static native int bind(long sock, long sa); 155 156 163 public static native int listen(long sock, int backlog); 164 165 173 public static native long accept(long sock) 174 throws Exception ; 175 176 183 public static native int acceptfilter(long sock, String name, String args); 184 185 191 public static native boolean atmark(long sock); 192 193 199 public static native int connect(long sock, long sa); 200 201 219 public static native int send(long sock, byte[] buf, int offset, int len); 220 221 242 public static native int sendb(long sock, ByteBuffer buf, 243 int offset, int len); 244 247 public static native int sendbb(long sock, 248 int offset, int len); 249 250 266 public static native int sendv(long sock, byte[][] vec); 267 268 276 public static native int sendto(long sock, long where, int flags, 277 byte[] buf, int offset, int len); 278 279 299 public static native int recv(long sock, byte[] buf, int offset, int nbytes); 300 301 322 public static native int recvt(long sock, byte[] buf, int offset, 323 int nbytes, long timeout); 324 325 345 public static native int recvb(long sock, ByteBuffer buf, 346 int offset, int nbytes); 347 350 public static native int recvbb(long sock, 351 int offset, int nbytes); 352 373 public static native int recvbt(long sock, ByteBuffer buf, 374 int offset, int nbytes, long timeout); 375 378 public static native int recvbbt(long sock, 379 int offset, int nbytes, long timeout); 380 381 390 public static native int recvFrom(long from, long sock, int flags, 391 byte[] buf, int offset, int nbytes); 392 393 415 public static native int optSet(long sock, int opt, int on); 416 417 436 public static native int optGet(long sock, int opt) 437 throws Exception ; 438 439 450 public static native int timeoutSet(long sock, long t); 451 452 457 public static native long timeoutGet(long sock) 458 throws Exception ; 459 460 481 public static native long sendfile(long sock, long file, byte [][] headers, 482 byte[][] trailers, long offset, 483 long len, int flags); 484 485 488 public static native long sendfilen(long sock, long file, long offset, 489 long len, int flags); 490 491 495 public static native long pool(long thesocket) 496 throws Exception ; 497 498 510 private static native long get(long socket, int what); 511 512 519 public static native void setsbb(long sock, ByteBuffer buf); 520 521 528 public static native void setrbb(long sock, ByteBuffer buf); 529 } 530 | Popular Tags |