Struct strymon_communication::Network
[−]
[src]
pub struct Network { /* fields omitted */ }
Handle to the networking subsystem.
Currently, this handle only stores information about the externally reachable hostname of the current process. In the future, it might be backed by a dedicated networking thread to implement its methods. Thus it recommended to only initialize it once per process.
Methods
impl Network
[src]
pub fn new<T: Into<Option<String>>>(hostname: T) -> Result<Self>
[src]
Creates a new default network handle.
The hostname
argument should be set to an externally reachable
hostname of the current process. If it is None
, this constructor
will try to retrieve it by reading the STRYMON_COMM_HOSTNAME
environment
variable. If both the argument and the environment variable are missing,
it falls back to "localhost"
.
pub fn hostname(&self) -> String
[src]
Returns the configured externally reachable hostname of the current process.
impl Network
[src]
pub fn connect<E: ToSocketAddrs>(
&self,
endpoint: E
) -> Result<(Sender, Receiver)>
[src]
&self,
endpoint: E
) -> Result<(Sender, Receiver)>
Connects to a socket returns two queue handles.
The endpoint socket is typically specified a (host, port)
pair. The returned
queue handles can be used to send and receive MessageBuf
objects on that socket.
Please refer to the transport
module level documentation
for more details.
pub fn listen<P: Into<Option<u16>>>(&self, port: P) -> Result<Listener>
[src]
Opens a new socket and returns a handle to receive incomming clients.
If the port
is not specified, a random ephemerial port is chosen.
Please refer to the transport
module level documentation
for more details.
impl Network
[src]
pub fn client<N: Name, E: ToSocketAddrs>(
&self,
endpoint: E
) -> Result<(Outgoing, Incoming<N>)>
[src]
&self,
endpoint: E
) -> Result<(Outgoing, Incoming<N>)>
Connects to an remote procedure call server.
Please refer to the rpc
module level documentation for more details.
pub fn server<N: Name, P: Into<Option<u16>>>(
&self,
port: P
) -> Result<Server<N>>
[src]
&self,
port: P
) -> Result<Server<N>>
Creates a new remote procedure call server.
If the port
is not specified, a random ephemerial port is chosen.
Please refer to the rpc
module level documentation for more details.
impl Network
[src]
pub fn upload<P: AsRef<Path>>(&self, path: P) -> Result<Handle>
[src]
Serves the specified file on a ephemerial network port.
pub fn download<P: AsRef<Path>>(&self, url: &str, path: P) -> Result<()>
[src]
Downloads the file served at url
and downloads it into path
.
Trait Implementations
impl Clone for Network
[src]
fn clone(&self) -> Network
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more