TcpListener
type TcpListener = TcpListener
Implementions
Methods
bind
pub fn bind(addr: TcpAddr | string): TcpListener throws IoError
[src]
pub fn bind(addr: TcpAddr | string): TcpListener throws IoError {
switch (let addr = addr.(type)) {
case TcpAddr:
let listener = try _TcpListener.bind(addr as _TcpAddr);
return listener as TcpListener;
case string:
let addr = try TcpAddr.parse(addr).ok_or_else(|| IoError.other("invalid address"));
let listener = try _TcpListener.bind(addr as _TcpAddr);
return listener as TcpListener;
}
}
Creates a new TcpListener
, which will be bound to the specified address.
bind
pub fn bind(addr: TcpAddr | string): TcpListener throws IoError
[src]
pub fn bind(addr: TcpAddr | string): TcpListener throws IoError {
switch (let addr = addr.(type)) {
case TcpAddr:
let listener = try _TcpListener.bind(addr as _TcpAddr);
return listener as TcpListener;
case string:
let addr = try TcpAddr.parse(addr).ok_or_else(|| IoError.other("invalid address"));
let listener = try _TcpListener.bind(addr as _TcpAddr);
return listener as TcpListener;
}
}
Creates a new TcpListener
, which will be bound to the specified address.
Creates a new TcpListener
, which will be bound to the specified address.
The returned listener is ready for accepting connections.
Binding with a port number of 0 will request that the OS assigns a port
to this listener. The port allocated can be queried via the local_addr
method.
accept_tcp
pub fn accept_tcp(self): TcpConnection throws IoError
[src]
pub fn accept_tcp(self): TcpConnection throws IoError {
return try (self as _TcpListener).accept_tcp() as TcpConnection;
}
Accepts a new incoming TCP connection from this listener.
accept_tcp
pub fn accept_tcp(self): TcpConnection throws IoError
[src]
pub fn accept_tcp(self): TcpConnection throws IoError {
return try (self as _TcpListener).accept_tcp() as TcpConnection;
}
Accepts a new incoming TCP connection from this listener.
Accepts a new incoming TCP connection from this listener.
This function will yield once a new TCP connection is established. When established, the corresponding TcpStream containing the remote peer's address will be returned.
[src]
pub fn tcp_addr(self): TcpAddr throws IoError {
return try (self as _TcpListener).local_addr() as TcpAddr;
}
Returns the listener's network address.
[src]
pub fn tcp_addr(self): TcpAddr throws IoError {
return try (self as _TcpListener).local_addr() as TcpAddr;
}
Returns the listener's network address.
Returns the listener's network address.
accept
pub fn accept(self): Connection throws IoError
[src]
pub fn accept(self): Connection throws IoError {
return try self.accept_tcp();
}
accept
pub fn accept(self): Connection throws IoError
[src]
pub fn accept(self): Connection throws IoError {
return try self.accept_tcp();
}
[src]
pub fn close(self) throws IoError {
try (self as _TcpListener).close();
}
[src]
pub fn close(self) throws IoError {
try (self as _TcpListener).close();
}