Change ServerSocket class so we don't have to subclass it...
[IRC.git] / Robust / src / ClassLibrary / ServerSocket.java
1 public class ServerSocket {
2     /* Socket pending flag */
3     external flag SocketPending;    
4     /* File Descriptor */
5     int fd;
6
7     private native int createSocket(int port);
8
9     public ServerSocket(int port) {
10         this.fd=createSocket(port);
11     }
12     
13     public Socket accept() {
14         Socket s=new Socket();
15         int newfd=nativeaccept(s);
16         s.setFD(newfd);
17         return s;
18     }
19
20     /* Lets caller pass in their own Socket object. */
21     public void accept(Socket s) {
22         int newfd=nativeaccept(s);
23         s.setFD(newfd);
24     }
25
26     private native int nativeaccept(Socket s);
27     
28     public void close();
29
30 }