# Struct ethcore_network::NetworkContext [−] [src]

    pub struct NetworkContext<'s> { /* fields omitted */ }

IO access point. This is passed to all IO handlers and provides an interface to the IO subsystem.

## Methods

### `impl<'s> NetworkContext<'s>`
[src]

#### `fn send(&self,
peer: PeerId,
packet_id: PacketId,
data: Vec<u8>)
-> Result<(), NetworkError>`

Send a packet over the network to another peer.

#### `fn send_protocol(&self,
protocol: ProtocolId,
peer: PeerId,
packet_id: PacketId,
data: Vec<u8>)
-> Result<(), NetworkError>`

Send a packet over the network to another peer using specified protocol.

#### `fn respond(&self,
packet_id: PacketId,
data: Vec<u8>)
-> Result<(), NetworkError>`

Respond to a current network message. Panics if no there is no packet in the context. If the session is expired returns nothing.

#### `fn io_channel(&self) -> IoChannel<NetworkIoMessage>`

Get an IoChannel.

#### `fn disable_peer(&self, peer: PeerId)`

Disconnect a peer and prevent it from connecting again.

#### `fn disconnect_peer(&self, peer: PeerId)`

Disconnect peer. Reconnect can be attempted later.

#### `fn is_expired(&self) -> bool`

Check if the session is still active.

#### `fn register_timer(&self, token: TimerToken, ms: u64) -> Result<(), NetworkError>`

Register a new IO timer. 'IoHandler::timeout' will be called with the token.

#### `fn peer_client_version(&self, peer: PeerId) -> String`

Returns peer identification string

#### `fn session_info(&self, peer: PeerId) -> Option<SessionInfo>`

Returns information on p2p session

#### `fn protocol_version(&self, protocol: ProtocolId, peer: PeerId) -> Option<u8>`

Returns max version for a given protocol.

#### `fn subprotocol_name(&self) -> ProtocolId`

Returns this object's subprotocol name.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)