Resource: RNetwork

global resource RNetwork
  operations
    initialize ()
      "Initialize the RNetwork object (called when execution starts)."
    terminate ()
      "Finalize the RNetwork (called just before execution terminates)."

    preOpenConnection (connection: RNetConnection)
      "Called before opening connection (might not know local port)."
    postOpenConnection (connection: RNetConnection)
      "Called after opening connection."
    closeConnection (connection: RNetConnection)
      "Called after closing connection."

    preOpenListener (listener: RNetListener)
      "Called before opening listener for server connections."
    postOpenListener (listener: RNetListener)
      "Called after opening listener for server connections."
    closeListener (listener: RNetListener)
      "Called after closing listener."

    preAccept (listener: RNetListener)
      "Called before listening for clients on listener."
    postAccept (listener: RNetListener, connection: RNetConnection)
      "Called after accepting connection using listener."

    openDatagramPort (port: RNetListener)
      "Called before opening port to listen for datagrams."
    closeDatagramPort (port: RNetListener)
      "Called before closing port."

    
    group connectRemoteAddress (address: RNetAddress)
       preOpenConnection (connection: RNetConnection
           : connectRemoteAddress (connection.getRemoteAddress ()),
       postAccept (listener: RNetListener, connection: RNetConnection
           : connectRemoteAddress (connection.getRemoteAddress ()),
       preSendDatagram (local: RNetAddress, remote: RNetAddress, nbytes: int) 
           : connectRemoteAddress (remote),
       // can't know *remote* before receive for datagrams
       postReceiveDatagram (local: RNetAddress, remote: RNetAddress, nbytes: int) 
           : connectRemoteAddress (remote);

    // Sending/Receiving

    preSendDatagram (local: RNetAddress, remote: RNetAddress, nbytes: int)
      "Called before up to nbytes are sent from local to remote."
    postSendDatagram (local: RNetAddress, remote: RNetAddress, nbytes: int)
      "Called after nbytes are sent from local to remote."

    preReceiveDatagram (local: RNetAddress, nbytes: int)
      "Called before a datagram of up to nbytes may be received at local."
    postReceiveDatagram (local: RNetAddress, remote: RNetAddress, nbytes: int)
      "Called after nbytes are received from remote to local."

    preSendConnection (connection: RNetConnection, nbytes: int) 
      "Called before up to nbytes are sent through connection."
    postSendConnection (connection: RNetConnection, nbytes: int)
      "Called after nbytes are sent through connection."

    preReceiveConnection (connection: RNetConnection, nbytes: int) 
        "Called before up to nbytes are received through connection."
    postReceiveConnection (connection: RNetConnection, nbytes: int) 
        "Called after up to nbytes are received through connection."

    group preSend (remote: RNetAddress, nbytes: int)
        preSendDatagram (local: RNetAddress, remote: RNetAddress, nbytes: int) 
            : preSend (remote, nbytes),
        preSendConnection (connection: RNetConnection, nbytes: int) 
            : preSend (connection.getRemoteAddress (), nbytes);

    group postSend (remote: RNetAddress, nbytes: int)
        postSendDatagram (local: RNetAddress, remote: RNetAddress, nbytes: int) 
            : postSend (remote, nbytes),
        postSendConnection (connection: RNetConnection, nbytes: int) 
            : postSend (connection.getRemoteAddress (), nbytes);

    group preReceive (remote: RNetAddress, nbytes: int)
        preReceiveDatagram (local: RNetAddress, nbytes: int) 
            : preReceive (null, nbytes),
        preReceiveConnection (connection: RNetConnection, nbytes: int) 
            : preReceive (connection.getRemoteAddress (), nbytes);

    group postReceive (remote: RNetAddress, nbytes: int)
        postReceiveDatagram (local: RNetAddress, remote: RNetAddress, nbytes: int) 
            : postReceive (remote, nbytes),
        postReceiveConnection (connection: RNetConnection, nbytes: int) 
            : postReceive (connection.getRemoteAddress (), nbytes);

    // Multicasting

    joinMulticastGroup (address: RNetAddress)
      "Called before joining a multicast group address."
    leaveMulticastGroup (address: RNetAddress)
      "Called before leaving a multicast group address."

    // Observing

    revealHostname (name: String)
      "Called before hostname name is revealed."

    revealLocalHostname ()
      "Called before local hostname is revealed."

About this file

Naccio Home Page
David Evans
University of Virginia, Computer Science