5 SocketOutputStream sout;
8 sin=new SocketInputStream(this);
9 sout=new SocketOutputStream(this);
12 public InputStream getInputStream() {
16 public OutputStream getOutputStream() {
20 public Socket(String host, int port) {
21 InetAddress address=InetAddress.getByName(host);
22 fd=nativeBind(address.getAddress(), port);
23 nativeConnect(fd, address.getAddress(), port);
24 sin=new SocketInputStream(this);
25 sout=new SocketOutputStream(this);
28 public Socket(InetAddress address, int port) {
29 fd=nativeBind(address.getAddress(), port);
30 nativeConnect(fd, address.getAddress(), port);
31 sin=new SocketInputStream(this);
32 sout=new SocketOutputStream(this);
35 public static native int nativeBind(byte[] address, int port);
37 public static native int nativeConnect(int fd, byte[] address, int port);
39 int setFD(int filed) {
43 public int read(byte[] b) {
46 public void write(byte[] b) {
47 nativeWrite(b, 0, b.length);
50 public void write(byte[] b, int offset, int len) {
51 nativeWrite(b, offset, len);
54 private native int nativeRead(byte[] b);
55 private native void nativeWrite(byte[] b, int offset, int len);
56 private native void nativeClose();