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

    pub struct NetworkService { /* fields omitted */ }

IO Service with networking `Message` defines a notification data type.

## Methods

### `impl NetworkService`
[src]

#### `fn new(config: NetworkConfiguration) -> Result<NetworkService, NetworkError>`

Starts IO event loop

#### `fn register_protocol(&self,
handler: Arc<NetworkProtocolHandler + Send + Sync>,
protocol: ProtocolId,
packet_count: u8,
versions: &[u8])
-> Result<(), NetworkError>`

Regiter a new protocol handler with the event loop.

#### `fn host_info(&self) -> String`

Returns host identifier string as advertised to other peers

#### `fn io(&self) -> &IoService<NetworkIoMessage>`

Returns underlying io service.

#### `fn stats(&self) -> &NetworkStats`

Returns network statistics.

#### `fn config(&self) -> &NetworkConfiguration`

Returns network configuration.

#### `fn external_url(&self) -> Option<String>`

Returns external url if available.

#### `fn local_url(&self) -> Option<String>`

Returns external url if available.

#### `fn start(&self) -> Result<(), NetworkError>`

Start network IO

#### `fn stop(&self) -> Result<(), NetworkError>`

Stop network IO

#### `fn connected_peers(&self) -> Vec<PeerId>`

Get a list of all connected peers by id.

#### `fn add_reserved_peer(&self, peer: &str) -> Result<(), NetworkError>`

Try to add a reserved peer.

#### `fn remove_reserved_peer(&self, peer: &str) -> Result<(), NetworkError>`

Try to remove a reserved peer.

#### `fn set_non_reserved_mode(&self, mode: NonReservedPeerMode)`

Set the non-reserved peer mode.

#### `fn with_context<F>(&self, protocol: ProtocolId, action: F) where F: Fn(&NetworkContext)`

Executes action in the network context

#### `fn with_context_eval<F, T>(&self, protocol: ProtocolId, action: F) -> Option<T> where F: Fn(&NetworkContext) -> T`

Evaluates function in the network context

## Trait Implementations

### `impl MayPanic for NetworkService`
[src]

#### `fn on_panic<F>(&self, closure: F) where F: OnPanicListener`

`closure` will be invoked whenever panic in thread is caught

# 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`)