pub struct Socket { /* private fields */ }
Expand description
Wrapper around UdpSocket.
Implementations§
Source§impl Socket
impl Socket
Sourcepub fn new(port: u16) -> Self
pub fn new(port: u16) -> Self
Create a new Socket.
This function binds to the computer’s local IP address. To
bind to a custom address, use Socket::new_any_ip()
Sourcepub fn new_any_ip<A: ToSocketAddrs>(addr: A) -> Self
pub fn new_any_ip<A: ToSocketAddrs>(addr: A) -> Self
Create a new Socket bound to any IP address.
Sourcepub fn get(&self) -> Option<(SocketAddr, String)>
pub fn get(&self) -> Option<(SocketAddr, String)>
Get a message, if one is waiting.
Returns the sender’s SocketAddr
, and a String
containing
the message text itself.
Returns None
if there are no waiting messages.
Sourcepub fn send(&mut self, address: &SocketAddr, message: String)
pub fn send(&mut self, address: &SocketAddr, message: String)
Send a message.
Auto Trait Implementations§
impl Freeze for Socket
impl RefUnwindSafe for Socket
impl Send for Socket
impl Sync for Socket
impl Unpin for Socket
impl UnwindSafe for Socket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more