This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
1 public class Socket {
2     /* File Descriptor */
3     int fd;
4     
5     public Socket() {
6     }
7
8     public Socket(String host, int port) {
9         InetAddress address=InetAddress.getByName(host);
10         fd=nativeBind(address.getAddress(), port);
11         nativeConnect(fd, address.getAddress(), port);
12     }
13     
14     public Socket(InetAddress address, int port) {
15         fd=nativeBind(address.getAddress(), port);
16         nativeConnect(fd, address.getAddress(), port);
17     }
18
19     public static native int nativeBind(byte[] address, int port);
20
21     public static native int nativeConnect(int fd, byte[] address, int port);
22     
23     int setFD(int filed) {
24         fd=filed;
25     }
26
27     public int read(byte[] b) {
28         return nativeRead(b);
29     }
30     public void write(byte[] b) {
31         nativeWrite(b);
32     }
33
34     private native int nativeRead(byte[] b);
35     private native void nativeWrite(byte[] b);
36     private native void nativeClose();
37
38     public void close() {
39         nativeClose();
40     }
41 }