Struct zmq_pw::Socket [] [src]

pub struct Socket { /* fields omitted */ }

A socket, the central object in 0MQ.

Methods

impl Socket
[src]

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.

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.

Return the inner pointer to this Socket.

WARNING: It is your responsibility to make sure that the underlying memory is not freed too early.

Accept connections on a socket.

Connect a socket.

Disconnect a previously connected socket

Send a message.

Due to the provided From implementations, this works for &[u8], Vec<u8> and &str Message itself.

Deprecated since 0.9.0

: Use send instead

Send a Message message.

Deprecated since 0.9.0

: Use send instead

Receive a message into a Message. The length passed to zmq_msg_recv is the length of the buffer.

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.

Receive a message into a fresh Message.

Receive a message as a byte vector.

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.

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.

Accessor for the ZMQ_IPV6 option.

Accessor for the ZMQ_IPV6 option.

Accessor for the ZMQ_IMMEDIATE option.

Accessor for the ZMQ_IMMEDIATE option.

Accessor for the ZMQ_PLAIN_SERVER option.

Accessor for the ZMQ_PLAIN_SERVER option.

Accessor for the ZMQ_CONFLATE option.

Accessor for the ZMQ_CONFLATE option.

Return the type of this socket.

Return true if there are more frames of a multipart message to receive.

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.

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_pw;
let ctx = zmq_pw::Context::new();
let socket = ctx.socket(zmq_pw::REQ).unwrap();
let events = socket.get_events().unwrap();
if events.contains(zmq_pw::POLLIN) {
  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.

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).

Set the ZMQ_CURVE_PUBLICKEY option value.

The key is returned as raw bytes. Use z85_encode on the resulting data to get the Z85-encoded string representation of the key.

Get the ZMQ_CURVE_SECRETKEY option value.

The key is returned as raw bytes. Use z85_encode on the resulting data to get the Z85-encoded string representation of the key.

Get ZMQ_CURVE_SERVERKEY option value.

Note that the key is returned as raw bytes, as a 32-byte vector. Use z85_encode() explicitly to obtain the Z85-encoded string variant.

Create a PollItem from the socket.

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

impl Send for Socket
[src]

impl Drop for Socket
[src]

A method called when the value goes out of scope. Read more