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 int connect(String host, int port) {
36 InetAddress address=InetAddress.getByName(host);
37 if (address != null) {
38 fd=nativeBind(address.getAddress(), port);
39 nativeConnect(fd, address.getAddress(), port);
47 public static native int nativeBind(byte[] address, int port);
49 public static native int nativeConnect(int fd, byte[] address, int port);
51 int setFD(int filed) {
55 public int read(byte[] b) {
58 public int write(byte[] b) {
59 nativeWrite(b, 0, b.length);
61 System.out.println("here: " + "fd= " + fd);
68 public int write(byte[] b, int offset, int len) {
69 nativeWrite(b, offset, len);
76 private native int nativeRead(byte[] b);
77 private native void nativeWrite(byte[] b, int offset, int len);
78 private native void nativeClose();