Interface NetworkTrafficListener
A listener for raw network traffic within Jetty.
NetworkTrafficListener
s can be installed in a
org.eclipse.jetty.server.NetworkTrafficServerConnector
,
and are notified of the following network traffic events:
- Connection opened, when the server has accepted the connection from a remote client
- Incoming bytes, when the server receives bytes sent from a remote client
- Outgoing bytes, when the server sends bytes to a remote client
- Connection closed, when the server has closed the connection to a remote client
NetworkTrafficListener
s can be used to log the network traffic viewed by
a Jetty server (for example logging to filesystem) for activities such as debugging
or request/response cycles or for replaying request/response cycles to other servers.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
Callback method invoked when a connection to a remote client has been closed.default void
incoming
(Socket socket, ByteBuffer bytes) Callback method invoked when bytes sent by a remote client arrived on the server.default void
Callback method invoked when a connection from a remote client has been accepted.default void
outgoing
(Socket socket, ByteBuffer bytes) Callback method invoked when bytes are sent to a remote client from the server.
-
Method Details
-
opened
Callback method invoked when a connection from a remote client has been accepted.
The
socket
parameter can be used to extract socket address information of the remote client.- Parameters:
socket
- the socket associated with the remote client
-
incoming
Callback method invoked when bytes sent by a remote client arrived on the server.
- Parameters:
socket
- the socket associated with the remote clientbytes
- the read-only buffer containing the incoming bytes
-
outgoing
Callback method invoked when bytes are sent to a remote client from the server.
This method is invoked after the bytes have been actually written to the remote client.
- Parameters:
socket
- the socket associated with the remote clientbytes
- the read-only buffer containing the outgoing bytes
-
closed
Callback method invoked when a connection to a remote client has been closed.
The
socket
parameter is already closed when this method is called, so it cannot be queried for socket address information of the remote client.
However, thesocket
parameter is the same object passed toopened(Socket)
, so it is possible to map socket information inopened(Socket)
and retrieve it in this method.- Parameters:
socket
- the (closed) socket associated with the remote client
-