Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rice.pastry
Interface NetworkListener

    public interface NetworkListener

Represents a listener to pastry network activity. This interface will notify you of opening/closing sockets, and all network traffic.

You hear about opening/closing sockets via `channelOpened()`/`channelClosed()` methods.

You hear about network input via `dataReceived()` and network output via `dataSent()`.

channelOpened() has a reason for opening the chanel. The reason falls under matrix of reasons:

- It may have been initiated locally, or be accepting of the socket from a remote node. Reasons who's name has ACC in them are accepted, all of the rest are initiated locally.
- It may be for a Normal connection, a source route (SR), a bootstrap (which just requests internal state from FreePastry) or for an application level socket.

There are currently the following limitations for NetworkListener regarding Application Sockets which may be fixed later:

1. when accepting an application socket the reason is REASON_ACC_NORMAL
2. you are not notified about data to/from these sockets, only that they have been opened.

the `dataSent()`/`dataReceived()` methods include a wireType. These tell you if the data was TCP/UDP and wether it was part of the SourceRoute

Version:
  $Id: NetworkListener.java 3613 2007-02-15 14:45:14Z jstewart $
Author:
  Jeff Hoye

Field Summary
`static int` | `REASON_ACC_BOOTSTRAP` Remote node opened a to acquire bootstrap information.
`static int` | `REASON_ACC_NORMAL` Remote node opened a socket for normal FreePastry traffic.
`static int` | `REASON_ACC_SR` Remote node opened a socket for source routing.
`static int` | `REASON_APP_SOCKET_NORMAL` Local node opened an application level socket.
`static int` | `REASON_BOOTSTRAP` Local node opened a to acquire bootstrap information.
`static int` | `REASON_NORMAL` Local node opened a socket for normal FreePastry traffic.
`static int` | `REASON_SR` Local node opened a socket for source routing.
`static int` | `TYPE_SR_TCP` TCP traffic source-routed (you are an intermediate hop, not the source nor destination)
`static int` | `TYPE_SR_UDP` UDP traffic source-routed (you are an intermediate hop, not the source nor destination)
`static int` | `TYPE_TCP` TCP traffic (not source-routed)
`static int` | `TYPE_UDP` UDP traffic (not source-routed)

Method Summary
`void` | `channelClosed(java.net.InetSocketAddress addr)` Called when a socket is closed.
`void` | `channelOpened(java.net.InetSocketAddress addr, int reason)` Called when a socket is opened.
`void` | `dataReceived(int msgAddress, short msgType, java.net.InetSocketAddress socketAddress, int size, int wireType)` called when data is received.
`void` | `dataSent(int msgAddress, short msgType, java.net.InetSocketAddress socketAddress, int size, int wireType)` called when data is sent.

Field Detail

### TYPE_TCP

    static final int TYPE_TCP

  TCP traffic (not source-routed)

  See Also:
    Constant Field Values

### TYPE_UDP

    static final int TYPE_UDP

  UDP traffic (not source-routed)

  See Also:
    Constant Field Values

### TYPE_SR_TCP

    static final int TYPE_SR_TCP

  TCP traffic source-routed (you are an intermediate hop, not the source nor destination)

  See Also:
    Constant Field Values

### TYPE_SR_UDP

    static final int TYPE_SR_UDP

  UDP traffic source-routed (you are an intermediate hop, not the source nor destination)

  See Also:
    Constant Field Values

### REASON_NORMAL

    static final int REASON_NORMAL

  Local node opened a socket for normal FreePastry traffic.

  See Also:
    Constant Field Values

### REASON_SR

    static final int REASON_SR

  Local node opened a socket for source routing.

  See Also:
    Constant Field Values

### REASON_BOOTSTRAP

    static final int REASON_BOOTSTRAP

  Local node opened a to acquire bootstrap information.

  See Also:
    Constant Field Values

### REASON_ACC_NORMAL

    static final int REASON_ACC_NORMAL

  Remote node opened a socket for normal FreePastry traffic.

  See Also:
    Constant Field Values

### REASON_ACC_SR

    static final int REASON_ACC_SR

  Remote node opened a socket for source routing.

  See Also:
    Constant Field Values

### REASON_ACC_BOOTSTRAP

    static final int REASON_ACC_BOOTSTRAP

  Remote node opened a to acquire bootstrap information.

  See Also:
    Constant Field Values

### REASON_APP_SOCKET_NORMAL

    static final int REASON_APP_SOCKET_NORMAL

  Local node opened an application level socket.

  See Also:
    Constant Field Values

Method Detail

### channelOpened

    void channelOpened(java.net.InetSocketAddress addr,
                       int reason)

  Called when a socket is opened.

  Parameters:
    `addr` - the address the socket was opened to
    `reason` - see above

### channelClosed

    void channelClosed(java.net.InetSocketAddress addr)

  Called when a socket is closed.

  Parameters:
    `addr` - the address the socket was opened to

### dataSent

    void dataSent(int msgAddress,
                  short msgType,
                  java.net.InetSocketAddress socketAddress,
                  int size,
                  int wireType)

  called when data is sent.

  Parameters:
    `msgAddress` - the application the message belongs to
    `msgType` - the type of message for that application
    `socketAddress` - the socket it is from
    `size` - the size of the message
    `wireType` - UDP/TCP

### dataReceived

    void dataReceived(int msgAddress,
                      short msgType,
                      java.net.InetSocketAddress socketAddress,
                      int size,
                      int wireType)

  called when data is received.

  Parameters:
    `msgAddress` - the application the message belongs to
    `msgType` - the type of message for that application
    `socketAddress` - the socket it is from
    `size` - the size of the message
    `wireType` - UDP/TCP

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005 - Rice Pastry.