wrapper java.net.ServerSocket requiredif RNetwork, RNetAddress, RNetConnection, RNetListener {
requires java.net.SocketHelp;
import naccio.library.Check;
import java.net.*;
state
public RNetListener rnl;
// Constructors
helper void rsetup (int port) {
if (port == 0) {
port = getLocalPort ();
}
rnl = new RNetListener (new RNetAddress (getInetAddress (), port));
RNetwork.postOpenListener (rnl);
}
helper static void preOpen (RNetAddress adr) {
RNetListener trnl;
trnl = new RNetListener (adr);
RNetwork.preOpenListener (trnl);
}
wrapper ServerSocket (int port) {
preOpen (new RNetAddress (SocketHelp.getLocalAddress (), port));
#;
rsetup (port);
}
wrapper ServerSocket (int port, int backlog) {
preOpen (new RNetAddress (SocketHelp.getLocalAddress (), port));
#;
rsetup (port);
}
wrapper ServerSocket (int port, int backlog, InetAddress bindAddr) {
preOpen (new RNetAddress (bindAddr, port));
#;
rsetup (port);
}
// Accepting Clients
wrapper Socket accept () {
util.Assert.assert (rnl != null);
RNetwork.preAccept (rnl);
#;
result.setupClientSocket (rnl);
RNetwork.postOpenConnection (result.rnc);
RNetwork.postAccept (rnl, result.rnc);
}
wrapper void close () {
#;
RNetwork.closeListener (rnl);
}
// User-defined SocketImpl objects
wrapper static synchronized void setSocketFactory (SocketImplFactory fac) {
NCheck.fatalViolation ("User-specified SocketImpl objects are not yet supported.");
#;
}
wrapper final void implAccept (Socket s) {
NCheck.fatalViolation ("User-specified SocketImpl objects are not yet supported.");
#;
}
}
Naccio Home Page
University of Virginia, Computer Science