[−][src]Struct zmq::Socket
A socket, the central object in 0MQ.
Methods
impl Socket
[src]
impl Socket
pub fn into_raw(self) -> *mut c_void
[src]
pub fn into_raw(self) -> *mut c_void
Consume the Socket and return the raw socket pointer.
Failure to close the raw socket manually or call from_raw
will lead to a memory leak. Also note that is function
relinquishes the reference on the context is was created from.
pub unsafe fn from_raw(sock: *mut c_void) -> Socket
[src]
pub unsafe fn from_raw(sock: *mut c_void) -> Socket
Create a Socket from a raw socket pointer.
The Socket assumes ownership of the pointer and will close the socket when it is dropped. The returned socket will not reference any context.
pub fn as_mut_ptr(&mut self) -> *mut c_void
[src]
pub fn as_mut_ptr(&mut self) -> *mut c_void
Return the inner pointer to this Socket.
WARNING: It is your responsibility to make sure that the underlying memory is not freed too early.
pub fn bind(&self, endpoint: &str) -> Result<()>
[src]
pub fn bind(&self, endpoint: &str) -> Result<()>
Accept connections on a socket.
pub fn connect(&self, endpoint: &str) -> Result<()>
[src]
pub fn connect(&self, endpoint: &str) -> Result<()>
Connect a socket.
pub fn disconnect(&self, endpoint: &str) -> Result<()>
[src]
pub fn disconnect(&self, endpoint: &str) -> Result<()>
Disconnect a previously connected socket
pub fn send(&self, data: &[u8], flags: i32) -> Result<()>
[src]
pub fn send(&self, data: &[u8], flags: i32) -> Result<()>
Send a &[u8]
message.
pub fn send_msg(&self, msg: Message, flags: i32) -> Result<()>
[src]
pub fn send_msg(&self, msg: Message, flags: i32) -> Result<()>
Send a Message
message.
pub fn send_str(&self, data: &str, flags: i32) -> Result<()>
[src]
pub fn send_str(&self, data: &str, flags: i32) -> Result<()>
pub fn send_multipart(&self, parts: &[&[u8]], flags: i32) -> Result<()>
[src]
pub fn send_multipart(&self, parts: &[&[u8]], flags: i32) -> Result<()>
pub fn recv(&self, msg: &mut Message, flags: i32) -> Result<()>
[src]
pub fn recv(&self, msg: &mut Message, flags: i32) -> Result<()>
Receive a message into a Message
. The length passed to zmq_msg_recv
is the length of the buffer.
pub fn recv_into(&self, bytes: &mut [u8], flags: i32) -> Result<usize>
[src]
pub fn recv_into(&self, bytes: &mut [u8], flags: i32) -> Result<usize>
Receive bytes into a slice. The length passed to zmq_recv
is the length of the slice. The
return value is the number of bytes in the message, which may be larger than the length of
the slice, indicating truncation.
pub fn recv_msg(&self, flags: i32) -> Result<Message>
[src]
pub fn recv_msg(&self, flags: i32) -> Result<Message>
Receive a message into a fresh Message
.
pub fn recv_bytes(&self, flags: i32) -> Result<Vec<u8>>
[src]
pub fn recv_bytes(&self, flags: i32) -> Result<Vec<u8>>
Receive a message as a byte vector.
pub fn recv_string(&self, flags: i32) -> Result<Result<String, Vec<u8>>>
[src]
pub fn recv_string(&self, flags: i32) -> Result<Result<String, Vec<u8>>>
Receive a String
from the socket.
If the received message is not valid UTF-8, it is returned as the original
Vec in the Err
part of the inner result.
pub fn recv_multipart(&self, flags: i32) -> Result<Vec<Vec<u8>>>
[src]
pub fn recv_multipart(&self, flags: i32) -> Result<Vec<Vec<u8>>>
Receive a multipart message from the socket.
Note that this will allocate a new vector for each message part; for many applications it will be possible to process the different parts sequentially and reuse allocations that way.
pub fn is_ipv6(&self) -> Result<bool>
[src]
pub fn is_ipv6(&self) -> Result<bool>
Accessor for the ZMQ_IPV6
option.
pub fn set_ipv6(&self, value: bool) -> Result<()>
[src]
pub fn set_ipv6(&self, value: bool) -> Result<()>
Accessor for the ZMQ_IPV6
option.
pub fn is_immediate(&self) -> Result<bool>
[src]
pub fn is_immediate(&self) -> Result<bool>
Accessor for the ZMQ_IMMEDIATE
option.
pub fn set_immediate(&self, value: bool) -> Result<()>
[src]
pub fn set_immediate(&self, value: bool) -> Result<()>
Accessor for the ZMQ_IMMEDIATE
option.
pub fn is_plain_server(&self) -> Result<bool>
[src]
pub fn is_plain_server(&self) -> Result<bool>
Accessor for the ZMQ_PLAIN_SERVER
option.
pub fn set_plain_server(&self, value: bool) -> Result<()>
[src]
pub fn set_plain_server(&self, value: bool) -> Result<()>
Accessor for the ZMQ_PLAIN_SERVER
option.
pub fn is_conflate(&self) -> Result<bool>
[src]
pub fn is_conflate(&self) -> Result<bool>
Accessor for the ZMQ_CONFLATE
option.
pub fn set_conflate(&self, value: bool) -> Result<()>
[src]
pub fn set_conflate(&self, value: bool) -> Result<()>
Accessor for the ZMQ_CONFLATE
option.
pub fn is_probe_router(&self) -> Result<bool>
[src]
pub fn is_probe_router(&self) -> Result<bool>
pub fn set_probe_router(&self, value: bool) -> Result<()>
[src]
pub fn set_probe_router(&self, value: bool) -> Result<()>
pub fn is_router_mandatory(&self) -> Result<bool>
[src]
pub fn is_router_mandatory(&self) -> Result<bool>
pub fn set_router_mandatory(&self, value: bool) -> Result<()>
[src]
pub fn set_router_mandatory(&self, value: bool) -> Result<()>
pub fn is_curve_server(&self) -> Result<bool>
[src]
pub fn is_curve_server(&self) -> Result<bool>
pub fn set_curve_server(&self, value: bool) -> Result<()>
[src]
pub fn set_curve_server(&self, value: bool) -> Result<()>
pub fn get_socket_type(&self) -> Result<SocketType>
[src]
pub fn get_socket_type(&self) -> Result<SocketType>
Return the type of this socket.
pub fn get_rcvmore(&self) -> Result<bool>
[src]
pub fn get_rcvmore(&self) -> Result<bool>
Return true if there are more frames of a multipart message to receive.
pub fn get_maxmsgsize(&self) -> Result<i64>
[src]
pub fn get_maxmsgsize(&self) -> Result<i64>
pub fn set_maxmsgsize(&self, value: i64) -> Result<()>
[src]
pub fn set_maxmsgsize(&self, value: i64) -> Result<()>
pub fn get_sndhwm(&self) -> Result<i32>
[src]
pub fn get_sndhwm(&self) -> Result<i32>
pub fn set_sndhwm(&self, value: i32) -> Result<()>
[src]
pub fn set_sndhwm(&self, value: i32) -> Result<()>
pub fn get_rcvhwm(&self) -> Result<i32>
[src]
pub fn get_rcvhwm(&self) -> Result<i32>
pub fn set_rcvhwm(&self, value: i32) -> Result<()>
[src]
pub fn set_rcvhwm(&self, value: i32) -> Result<()>
pub fn get_affinity(&self) -> Result<u64>
[src]
pub fn get_affinity(&self) -> Result<u64>
pub fn set_affinity(&self, value: u64) -> Result<()>
[src]
pub fn set_affinity(&self, value: u64) -> Result<()>
pub fn get_rate(&self) -> Result<i32>
[src]
pub fn get_rate(&self) -> Result<i32>
pub fn set_rate(&self, value: i32) -> Result<()>
[src]
pub fn set_rate(&self, value: i32) -> Result<()>
pub fn get_recovery_ivl(&self) -> Result<i32>
[src]
pub fn get_recovery_ivl(&self) -> Result<i32>
pub fn set_recovery_ivl(&self, value: i32) -> Result<()>
[src]
pub fn set_recovery_ivl(&self, value: i32) -> Result<()>
pub fn get_sndbuf(&self) -> Result<i32>
[src]
pub fn get_sndbuf(&self) -> Result<i32>
pub fn set_sndbuf(&self, value: i32) -> Result<()>
[src]
pub fn set_sndbuf(&self, value: i32) -> Result<()>
pub fn get_rcvbuf(&self) -> Result<i32>
[src]
pub fn get_rcvbuf(&self) -> Result<i32>
pub fn set_rcvbuf(&self, value: i32) -> Result<()>
[src]
pub fn set_rcvbuf(&self, value: i32) -> Result<()>
pub fn get_tos(&self) -> Result<i32>
[src]
pub fn get_tos(&self) -> Result<i32>
pub fn set_tos(&self, value: i32) -> Result<()>
[src]
pub fn set_tos(&self, value: i32) -> Result<()>
pub fn get_linger(&self) -> Result<i32>
[src]
pub fn get_linger(&self) -> Result<i32>
pub fn set_linger(&self, value: i32) -> Result<()>
[src]
pub fn set_linger(&self, value: i32) -> Result<()>
pub fn get_reconnect_ivl(&self) -> Result<i32>
[src]
pub fn get_reconnect_ivl(&self) -> Result<i32>
pub fn set_reconnect_ivl(&self, value: i32) -> Result<()>
[src]
pub fn set_reconnect_ivl(&self, value: i32) -> Result<()>
pub fn get_reconnect_ivl_max(&self) -> Result<i32>
[src]
pub fn get_reconnect_ivl_max(&self) -> Result<i32>
pub fn set_reconnect_ivl_max(&self, value: i32) -> Result<()>
[src]
pub fn set_reconnect_ivl_max(&self, value: i32) -> Result<()>
pub fn get_backlog(&self) -> Result<i32>
[src]
pub fn get_backlog(&self) -> Result<i32>
pub fn set_backlog(&self, value: i32) -> Result<()>
[src]
pub fn set_backlog(&self, value: i32) -> Result<()>
pub fn get_fd(&self) -> Result<RawFd>
[src]
pub fn get_fd(&self) -> Result<RawFd>
Get the event notification file descriptor.
Getter for the ZMQ_FD
option. Note that the returned
type is platform-specific; it aliases either
std::os::unix::io::RawFd
and or
std::os::windows::io::RawSocket
.
Note that the returned file desciptor has special
semantics: it should only used with an operating system
facility like Unix poll()
to check its readability.
pub fn get_events(&self) -> Result<i32>
[src]
pub fn get_events(&self) -> Result<i32>
Get the currently pending events.
Note that the result of this function can also change due
to receiving or sending a message on the socket, without
the signalling FD (see Socket::get_fd()
).
Examples
use zmq; let ctx = zmq::Context::new(); let socket = ctx.socket(zmq::REQ).unwrap(); let events = socket.get_events().unwrap() as zmq::PollEvents; if (events & zmq::POLLIN) != 0 { println!("socket readable") } drop(socket);
Compatibility
This function currently returns the bitmask as an i32
for backwards compatibility; in effect it should have been
using the same type as PollItem::get_revents()
all
along.
In the 0.9
series, this will be rectified.
pub fn get_multicast_hops(&self) -> Result<i32>
[src]
pub fn get_multicast_hops(&self) -> Result<i32>
pub fn set_multicast_hops(&self, value: i32) -> Result<()>
[src]
pub fn set_multicast_hops(&self, value: i32) -> Result<()>
pub fn get_rcvtimeo(&self) -> Result<i32>
[src]
pub fn get_rcvtimeo(&self) -> Result<i32>
pub fn set_rcvtimeo(&self, value: i32) -> Result<()>
[src]
pub fn set_rcvtimeo(&self, value: i32) -> Result<()>
pub fn get_sndtimeo(&self) -> Result<i32>
[src]
pub fn get_sndtimeo(&self) -> Result<i32>
pub fn set_sndtimeo(&self, value: i32) -> Result<()>
[src]
pub fn set_sndtimeo(&self, value: i32) -> Result<()>
pub fn get_tcp_keepalive(&self) -> Result<i32>
[src]
pub fn get_tcp_keepalive(&self) -> Result<i32>
pub fn set_tcp_keepalive(&self, value: i32) -> Result<()>
[src]
pub fn set_tcp_keepalive(&self, value: i32) -> Result<()>
pub fn get_tcp_keepalive_cnt(&self) -> Result<i32>
[src]
pub fn get_tcp_keepalive_cnt(&self) -> Result<i32>
pub fn set_tcp_keepalive_cnt(&self, value: i32) -> Result<()>
[src]
pub fn set_tcp_keepalive_cnt(&self, value: i32) -> Result<()>
pub fn get_tcp_keepalive_idle(&self) -> Result<i32>
[src]
pub fn get_tcp_keepalive_idle(&self) -> Result<i32>
pub fn set_tcp_keepalive_idle(&self, value: i32) -> Result<()>
[src]
pub fn set_tcp_keepalive_idle(&self, value: i32) -> Result<()>
pub fn get_tcp_keepalive_intvl(&self) -> Result<i32>
[src]
pub fn get_tcp_keepalive_intvl(&self) -> Result<i32>
pub fn set_tcp_keepalive_intvl(&self, value: i32) -> Result<()>
[src]
pub fn set_tcp_keepalive_intvl(&self, value: i32) -> Result<()>
pub fn get_handshake_ivl(&self) -> Result<i32>
[src]
pub fn get_handshake_ivl(&self) -> Result<i32>
pub fn set_handshake_ivl(&self, value: i32) -> Result<()>
[src]
pub fn set_handshake_ivl(&self, value: i32) -> Result<()>
pub fn set_identity(&self, value: &[u8]) -> Result<()>
[src]
pub fn set_identity(&self, value: &[u8]) -> Result<()>
pub fn set_subscribe(&self, value: &[u8]) -> Result<()>
[src]
pub fn set_subscribe(&self, value: &[u8]) -> Result<()>
pub fn set_unsubscribe(&self, value: &[u8]) -> Result<()>
[src]
pub fn set_unsubscribe(&self, value: &[u8]) -> Result<()>
pub fn get_identity(&self) -> Result<Result<String, Vec<u8>>>
[src]
pub fn get_identity(&self) -> Result<Result<String, Vec<u8>>>
pub fn get_socks_proxy(&self) -> Result<Result<String, Vec<u8>>>
[src]
pub fn get_socks_proxy(&self) -> Result<Result<String, Vec<u8>>>
pub fn get_mechanism(&self) -> Result<Mechanism>
[src]
pub fn get_mechanism(&self) -> Result<Mechanism>
pub fn get_plain_username(&self) -> Result<Result<String, Vec<u8>>>
[src]
pub fn get_plain_username(&self) -> Result<Result<String, Vec<u8>>>
pub fn get_plain_password(&self) -> Result<Result<String, Vec<u8>>>
[src]
pub fn get_plain_password(&self) -> Result<Result<String, Vec<u8>>>
pub fn get_zap_domain(&self) -> Result<Result<String, Vec<u8>>>
[src]
pub fn get_zap_domain(&self) -> Result<Result<String, Vec<u8>>>
pub fn get_last_endpoint(&self) -> Result<Result<String, Vec<u8>>>
[src]
pub fn get_last_endpoint(&self) -> Result<Result<String, Vec<u8>>>
Return the address of the last endpoint this socket was bound to.
Note that the returned address is not guaranteed to be the
same as the one used with bind
, and might also not be
directly usable with connect
. In particular, when bind
is
used with the wildcard address ("*"
), in the address
returned, the wildcard will be expanded into the any address
(i.e. 0.0.0.0
with IPv4).
pub fn get_curve_publickey(&self) -> Result<Result<String, Vec<u8>>>
[src]
pub fn get_curve_publickey(&self) -> Result<Result<String, Vec<u8>>>
pub fn get_curve_secretkey(&self) -> Result<Result<String, Vec<u8>>>
[src]
pub fn get_curve_secretkey(&self) -> Result<Result<String, Vec<u8>>>
pub fn get_curve_serverkey(&self) -> Result<Result<String, Vec<u8>>>
[src]
pub fn get_curve_serverkey(&self) -> Result<Result<String, Vec<u8>>>
pub fn set_socks_proxy(&self, value: Option<&str>) -> Result<()>
[src]
pub fn set_socks_proxy(&self, value: Option<&str>) -> Result<()>
pub fn set_plain_username(&self, value: Option<&str>) -> Result<()>
[src]
pub fn set_plain_username(&self, value: Option<&str>) -> Result<()>
pub fn set_plain_password(&self, value: Option<&str>) -> Result<()>
[src]
pub fn set_plain_password(&self, value: Option<&str>) -> Result<()>
pub fn set_zap_domain(&self, value: &str) -> Result<()>
[src]
pub fn set_zap_domain(&self, value: &str) -> Result<()>
pub fn set_curve_publickey(&self, value: &str) -> Result<()>
[src]
pub fn set_curve_publickey(&self, value: &str) -> Result<()>
pub fn set_curve_secretkey(&self, value: &str) -> Result<()>
[src]
pub fn set_curve_secretkey(&self, value: &str) -> Result<()>
pub fn set_curve_serverkey(&self, value: &str) -> Result<()>
[src]
pub fn set_curve_serverkey(&self, value: &str) -> Result<()>
pub fn as_poll_item(&self, events: PollEvents) -> PollItem
[src]
pub fn as_poll_item(&self, events: PollEvents) -> PollItem
Create a PollItem
from the socket.
pub fn poll(&self, events: PollEvents, timeout_ms: i64) -> Result<i32>
[src]
pub fn poll(&self, events: PollEvents, timeout_ms: i64) -> Result<i32>
Do a call to zmq_poll
with only this socket.
The return value on success will be either zero (no event) or one (some event was signaled).
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,