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