C# Class NetMQ.Core.SocketBase

Inheritance: NetMQ.Core.Own, IPollEvents, Pipe.IPipeEvents
Afficher le fichier Open project: NetMQ/NetMQ3-x Class Usage Examples

Private Properties

Свойство Type Description
AddEndpoint void
AttachPipe void
CheckContextTerminated void
CheckDestroy void
CheckProtocol void
Create SocketBase
DecodeAddress void
ExtractFlags void
GetTypeString string
MonitorEvent void
ProcessCommands void
StartReaping void
StopMonitor void

Méthodes publiques

Méthode Description
Bind ( [ addr ) : void

Bind this socket to the given address.

The supported protocols are "inproc", "ipc", "tcp", "pgm", and "epgm". If the protocol is either "pgm" or "epgm", then this socket must be of type Pub, Sub, XPub, or XSub. If the protocol is "inproc", you cannot bind to the same address more than once.

BindRandomPort ( [ addr ) : int

Bind the specified TCP address to an available port, assigned by the operating system.

CheckDisposed ( ) : void

Throw ObjectDisposedException if this socket is already disposed.

Close ( ) : void

Close this socket. Mark it as disposed, and send ownership of it to the reaper thread to attend to the rest of it's shutdown process.

Connect ( [ addr ) : void

Connect this socket to the given address.

The supported protocols are "inproc", "ipc", "tcp", "pgm", and "epgm". If the protocol is either "pgm" or "epgm", then this socket must be of type Pub, Sub, XPub, or XSub.

Destroy ( ) : void

Destroy this socket - which means to stop monitoring the queue for messages. This simply calls StopMonitor, and then verifies that the destroyed-flag is set.

EventAcceptFailed ( [ addr, ErrorCode errno ) : void
EventAccepted ( [ addr, [ ch ) : void
EventBindFailed ( [ addr, ErrorCode errno ) : void
EventCloseFailed ( [ addr, ErrorCode errno ) : void
EventClosed ( [ addr, [ ch ) : void
EventConnectDelayed ( [ addr, ErrorCode errno ) : void
EventConnectRetried ( [ addr, int interval ) : void
EventConnected ( [ addr, [ ch ) : void
EventDisconnected ( [ addr, [ ch ) : void
EventListening ( [ addr, [ ch ) : void
GetSocketOption ( ZmqSocketOption option ) : int

Return the integer-value of the specified option.

If the ReceiveMore option is specified, then 1 is returned if it is true, 0 if it is false. If the Events option is specified, then process any outstanding commands, and return -1 if that throws a TerminatingException. then return an integer that is the bitwise-OR of the PollEvents.PollOut and PollEvents.PollIn flags. Otherwise, cast the specified option value to an integer and return it.

GetSocketOptionX ( ZmqSocketOption option ) : object

Return the value of the specified option as an Object.

If the Handle option is specified, then return the handle of the contained mailbox. If the Events option is specified, then process any outstanding commands, and return -1 if that throws a TerminatingException. then return a PollEvents that is the bitwise-OR of the PollEvents.PollOut and PollEvents.PollIn flags.

HasIn ( ) : bool

These functions are used by the polling mechanism to determine which events are to be reported from this socket.

HasOut ( ) : bool

These functions are used by the polling mechanism to determine which events are to be reported from this socket.

Hiccuped ( NetMQ.Core.Pipe pipe ) : void
InEvent ( ) : void

Handle input-ready events by receiving and processing any incoming commands.

Monitor ( [ addr, SocketEvents events ) : void

Register the given events to monitor on the given endpoint.

OutEvent ( ) : void

Handle output-ready events.

ReadActivated ( NetMQ.Core.Pipe pipe ) : void

Indicate that the given pipe is now ready for reading. Pipe calls this on it's sink in response to ProcessActivateRead. When called upon an instance of SocketBase, this simply calls XReadActivated.

SetSocketOption ( ZmqSocketOption option, object optionValue ) : void

Set the specified socket option.

Stop ( ) : void

Interrupt a blocking call if the socket is stuck in one. This function can be called from a different thread!

TermEndpoint ( [ addr ) : void

Disconnect from the given endpoint.

Terminated ( NetMQ.Core.Pipe pipe ) : void

This gets called by ProcessPipeTermAck or XTerminated to respond to the termination of the given pipe.

TimerEvent ( int id ) : void

In subclasses of SocketBase this is overridden, to handle the expiration of a timer.

ToString ( ) : string

Override the ToString method in order to also show the socket-id.

TryRecv ( Msg &msg, System.TimeSpan timeout ) : bool

Receive a frame into the given msg and return true if successful, false if it timed out.

For timeout, there are three categories of value: TimeSpan.Zero - return false immediately if no message is available SendReceiveConstants.InfiniteTimeout (or a negative value) - wait indefinitely, always returning true Any positive value - return false after the corresponding duration if no message has become available

TrySend ( Msg &msg, System.TimeSpan timeout, bool more ) : bool

Transmit the given Msg across the message-queueing system.

WriteActivated ( NetMQ.Core.Pipe pipe ) : void

When called upon an instance of SocketBase, this simply calls XWriteActivated.

Méthodes protégées

Méthode Description
ProcessBind ( NetMQ.Core.Pipe pipe ) : void

Process a Bind command by attaching the given Pipe.

ProcessDestroy ( ) : void

Mark this socket as having been destroyed. Delay actual destruction of the socket.

ProcessStop ( ) : void

Process a termination command on this socket, by stopping monitoring and marking this as terminated.

ProcessTerm ( int linger ) : void

Process a termination request.

SocketBase ( [ parent, int threadId, int socketId ) : System

Create a new SocketBase within the given Ctx, with the specified thread-id and socket-id.

XAttachPipe ( [ pipe, bool icanhasall ) : void

Abstract method for attaching a given pipe to this socket. The concrete implementations are defined by the individual socket types.

XHasIn ( ) : bool

This gets called when incoming messages are ready to be received. On SocketBase, this does nothing and simply returns false.

XHasOut ( ) : bool

This gets called when outgoing messages are ready to be sent out. On SocketBase, this does nothing and simply returns false.

XHiccuped ( [ pipe ) : void
XReadActivated ( [ pipe ) : void

Indicate the given pipe as being ready for reading by this socket. This abstract method gets overridden by the different sockets to provide their own concrete implementation.

XRecv ( Msg &msg ) : bool

Receive a message. The Recv method calls this lower-level method to do the actual receiving. This abstract method gets overridden by the different socket types to provide their concrete implementation of receiving messages.

XSend ( Msg &msg ) : bool

Transmit the given message. The TrySend method calls this to do the actual sending. This abstract method gets overridden by the different socket types to provide their concrete implementation of sending messages.

XSetSocketOption ( ZmqSocketOption option, [ optionValue ) : bool

The default implementation assumes there are no specific socket options for the particular socket type. If not so, overload this method.

XTerminated ( [ pipe ) : void

Abstract method that gets called to signal that the given pipe is to be removed from this socket. The concrete implementations of SocketBase override this to provide their own implementation of how to terminate the pipe.

XWriteActivated ( [ pipe ) : void

Indicate the given pipe as being ready for writing to by this socket. This abstract method gets called by the WriteActivated method and gets overridden by the different sockets to provide their own concrete implementation.

Private Methods

Méthode Description
AddEndpoint ( [ address, [ endpoint, NetMQ.Core.Pipe pipe ) : void

Take ownership of the given endpoint and register it against the given address.

AttachPipe ( [ pipe, bool icanhasall = false ) : void

Register the given pipe with this socket.

CheckContextTerminated ( ) : void

Throw TerminatingException if the message-queueing system has started terminating.

CheckDestroy ( ) : void

To be called after processing commands or invoking any command handlers explicitly. If required, it will deallocate the socket.

CheckProtocol ( [ protocol ) : void

Check whether the transport protocol, as specified in connect or bind, is available and compatible with the socket type.

The supported protocols are "inproc", "ipc", "tcp", "pgm", and "epgm". If the protocol is either "pgm" or "epgm", then this socket must be of type Pub, Sub, XPub, or XSub.

Create ( ZmqSocketType type, [ parent, int threadId, int socketId ) : SocketBase
DecodeAddress ( [ addr, string &address, string &protocol ) : void

Given a string containing an endpoint address like "tcp://127.0.0.1:5555, break-it-down into the address part ("127.0.0.1:5555") and the protocol part ("tcp").

ExtractFlags ( Msg &msg ) : void

Moves the flags from the message to local variables, to be later retrieved by getsockopt.

GetTypeString ( ) : string
MonitorEvent ( [ monitorEvent ) : void
ProcessCommands ( int timeout, bool throttle ) : void

Processes commands sent to this socket (if any). If timeout is -1, the call blocks until at least one command was processed. If throttle is true, commands are processed at most once in a predefined time period.

StartReaping ( [ poller ) : void

Using this function reaper thread ask the socket to register with its poller.

StopMonitor ( ) : void

If there is a monitor-socket, close it and set monitor-events to 0.

Method Details

Bind() public méthode

Bind this socket to the given address.
The supported protocols are "inproc", "ipc", "tcp", "pgm", and "epgm". If the protocol is either "pgm" or "epgm", then this socket must be of type Pub, Sub, XPub, or XSub. If the protocol is "inproc", you cannot bind to the same address more than once.
the address specified to bind to must not be already in use The requested protocol is not supported. the socket bind failed No IO thread was found, or the protocol's listener encountered an /// error during initialisation. the specified protocol is not supported the socket type and protocol do not match The socket has been stopped.
public Bind ( [ addr ) : void
addr [ a string denoting the endpoint-address to bind to
Résultat void

BindRandomPort() public méthode

Bind the specified TCP address to an available port, assigned by the operating system.
uses a protocol other than TCP. The socket has been stopped. The specified address is already in use. No IO thread was found, or the protocol's listener errored during /// initialisation. the socket bind failed
public BindRandomPort ( [ addr ) : int
addr [ a string denoting the endpoint to bind to
Résultat int

CheckDisposed() public méthode

Throw ObjectDisposedException if this socket is already disposed.
This object is already disposed.
public CheckDisposed ( ) : void
Résultat void

Close() public méthode

Close this socket. Mark it as disposed, and send ownership of it to the reaper thread to attend to the rest of it's shutdown process.
public Close ( ) : void
Résultat void

Connect() public méthode

Connect this socket to the given address.
The supported protocols are "inproc", "ipc", "tcp", "pgm", and "epgm". If the protocol is either "pgm" or "epgm", then this socket must be of type Pub, Sub, XPub, or XSub.
The specified address is already in use. No IO thread was found. the specified protocol is not supported the socket type and protocol do not match The socket has been stopped. The given address was not found in the list of endpoints.
public Connect ( [ addr ) : void
addr [ a string denoting the endpoint to connect to
Résultat void

Destroy() public méthode

Destroy this socket - which means to stop monitoring the queue for messages. This simply calls StopMonitor, and then verifies that the destroyed-flag is set.
public Destroy ( ) : void
Résultat void

EventAcceptFailed() public méthode

public EventAcceptFailed ( [ addr, ErrorCode errno ) : void
addr [
errno ErrorCode
Résultat void

EventAccepted() public méthode

public EventAccepted ( [ addr, [ ch ) : void
addr [
ch [
Résultat void

EventBindFailed() public méthode

public EventBindFailed ( [ addr, ErrorCode errno ) : void
addr [
errno ErrorCode
Résultat void

EventCloseFailed() public méthode

public EventCloseFailed ( [ addr, ErrorCode errno ) : void
addr [
errno ErrorCode
Résultat void

EventClosed() public méthode

public EventClosed ( [ addr, [ ch ) : void
addr [
ch [
Résultat void

EventConnectDelayed() public méthode

public EventConnectDelayed ( [ addr, ErrorCode errno ) : void
addr [
errno ErrorCode
Résultat void

EventConnectRetried() public méthode

public EventConnectRetried ( [ addr, int interval ) : void
addr [
interval int
Résultat void

EventConnected() public méthode

public EventConnected ( [ addr, [ ch ) : void
addr [
ch [
Résultat void

EventDisconnected() public méthode

public EventDisconnected ( [ addr, [ ch ) : void
addr [
ch [
Résultat void

EventListening() public méthode

public EventListening ( [ addr, [ ch ) : void
addr [
ch [
Résultat void

GetSocketOption() public méthode

Return the integer-value of the specified option.
If the ReceiveMore option is specified, then 1 is returned if it is true, 0 if it is false. If the Events option is specified, then process any outstanding commands, and return -1 if that throws a TerminatingException. then return an integer that is the bitwise-OR of the PollEvents.PollOut and PollEvents.PollIn flags. Otherwise, cast the specified option value to an integer and return it.
The socket has been stopped.
public GetSocketOption ( ZmqSocketOption option ) : int
option ZmqSocketOption which option to get
Résultat int

GetSocketOptionX() public méthode

Return the value of the specified option as an Object.
If the Handle option is specified, then return the handle of the contained mailbox. If the Events option is specified, then process any outstanding commands, and return -1 if that throws a TerminatingException. then return a PollEvents that is the bitwise-OR of the PollEvents.PollOut and PollEvents.PollIn flags.
The socket has already been stopped.
public GetSocketOptionX ( ZmqSocketOption option ) : object
option ZmqSocketOption which option to get
Résultat object

HasIn() public méthode

These functions are used by the polling mechanism to determine which events are to be reported from this socket.
public HasIn ( ) : bool
Résultat bool

HasOut() public méthode

These functions are used by the polling mechanism to determine which events are to be reported from this socket.
public HasOut ( ) : bool
Résultat bool

Hiccuped() public méthode

public Hiccuped ( NetMQ.Core.Pipe pipe ) : void
pipe NetMQ.Core.Pipe
Résultat void

InEvent() public méthode

Handle input-ready events by receiving and processing any incoming commands.
public InEvent ( ) : void
Résultat void

Monitor() public méthode

Register the given events to monitor on the given endpoint.
Maximum number of sockets reached. The protocol of is not supported. The socket has been stopped.
public Monitor ( [ addr, SocketEvents events ) : void
addr [ a string denoting the endpoint to monitor. If this is null - monitoring is stopped.
events SocketEvents the SocketEvent to monitor for
Résultat void

OutEvent() public méthode

Handle output-ready events.
This is not supported on instances of the parent class SocketBase.
public OutEvent ( ) : void
Résultat void

ProcessBind() protected méthode

Process a Bind command by attaching the given Pipe.
protected ProcessBind ( NetMQ.Core.Pipe pipe ) : void
pipe NetMQ.Core.Pipe the Pipe to attach
Résultat void

ProcessDestroy() protected méthode

Mark this socket as having been destroyed. Delay actual destruction of the socket.
protected ProcessDestroy ( ) : void
Résultat void

ProcessStop() protected méthode

Process a termination command on this socket, by stopping monitoring and marking this as terminated.
protected ProcessStop ( ) : void
Résultat void

ProcessTerm() protected méthode

Process a termination request.
protected ProcessTerm ( int linger ) : void
linger int a time (in milliseconds) for this to linger before actually going away. -1 means infinite.
Résultat void

ReadActivated() public méthode

Indicate that the given pipe is now ready for reading. Pipe calls this on it's sink in response to ProcessActivateRead. When called upon an instance of SocketBase, this simply calls XReadActivated.
public ReadActivated ( NetMQ.Core.Pipe pipe ) : void
pipe NetMQ.Core.Pipe the pipe to indicate is ready for reading
Résultat void

SetSocketOption() public méthode

Set the specified socket option.
The socket has been stopped.
public SetSocketOption ( ZmqSocketOption option, object optionValue ) : void
option ZmqSocketOption which option to set
optionValue object the value to set the option to
Résultat void

SocketBase() protected méthode

Create a new SocketBase within the given Ctx, with the specified thread-id and socket-id.
protected SocketBase ( [ parent, int threadId, int socketId ) : System
parent [ the Ctx context that this socket will live within
threadId int the id of the thread upon which this socket will execute
socketId int the integer id for the new socket
Résultat System

Stop() public méthode

Interrupt a blocking call if the socket is stuck in one. This function can be called from a different thread!
public Stop ( ) : void
Résultat void

TermEndpoint() public méthode

Disconnect from the given endpoint.
is null. Endpoint was not found and cannot be disconnected. The specified protocol must be valid. The socket has been stopped.
public TermEndpoint ( [ addr ) : void
addr [ the endpoint to disconnect from
Résultat void

Terminated() public méthode

This gets called by ProcessPipeTermAck or XTerminated to respond to the termination of the given pipe.
public Terminated ( NetMQ.Core.Pipe pipe ) : void
pipe NetMQ.Core.Pipe the pipe that was terminated
Résultat void

TimerEvent() public méthode

In subclasses of SocketBase this is overridden, to handle the expiration of a timer.
You must not call TimerEvent on an instance of class SocketBase.
public TimerEvent ( int id ) : void
id int an integer used to identify the timer
Résultat void

ToString() public méthode

Override the ToString method in order to also show the socket-id.
public ToString ( ) : string
Résultat string

TryRecv() public méthode

Receive a frame into the given msg and return true if successful, false if it timed out.
For timeout, there are three categories of value: TimeSpan.Zero - return false immediately if no message is available SendReceiveConstants.InfiniteTimeout (or a negative value) - wait indefinitely, always returning true Any positive value - return false after the corresponding duration if no message has become available
the Msg must already have been uninitialised The socket must not already be stopped.
public TryRecv ( Msg &msg, System.TimeSpan timeout ) : bool
msg Msg the Msg to read the received message into
timeout System.TimeSpan this controls whether the call blocks, and for how long.
Résultat bool

TrySend() public méthode

Transmit the given Msg across the message-queueing system.
The socket has been stopped. is not initialised.
public TrySend ( Msg &msg, System.TimeSpan timeout, bool more ) : bool
msg Msg The to send.
timeout System.TimeSpan The timeout to wait before returning false. Pass to disable timeout.
more bool Whether this message will contain another frame after this one.
Résultat bool

WriteActivated() public méthode

When called upon an instance of SocketBase, this simply calls XWriteActivated.
public WriteActivated ( NetMQ.Core.Pipe pipe ) : void
pipe NetMQ.Core.Pipe the pipe to indicate is ready for writing
Résultat void

XAttachPipe() protected abstract méthode

Abstract method for attaching a given pipe to this socket. The concrete implementations are defined by the individual socket types.
protected abstract XAttachPipe ( [ pipe, bool icanhasall ) : void
pipe [ the Pipe to attach
icanhasall bool if true - subscribe to all data on the pipe
Résultat void

XHasIn() protected méthode

This gets called when incoming messages are ready to be received. On SocketBase, this does nothing and simply returns false.
protected XHasIn ( ) : bool
Résultat bool

XHasOut() protected méthode

This gets called when outgoing messages are ready to be sent out. On SocketBase, this does nothing and simply returns false.
protected XHasOut ( ) : bool
Résultat bool

XHiccuped() protected méthode

protected XHiccuped ( [ pipe ) : void
pipe [
Résultat void

XReadActivated() protected méthode

Indicate the given pipe as being ready for reading by this socket. This abstract method gets overridden by the different sockets to provide their own concrete implementation.
protected XReadActivated ( [ pipe ) : void
pipe [ the Pipe that is now becoming available for reading
Résultat void

XRecv() protected méthode

Receive a message. The Recv method calls this lower-level method to do the actual receiving. This abstract method gets overridden by the different socket types to provide their concrete implementation of receiving messages.
protected XRecv ( Msg &msg ) : bool
msg Msg the Msg to receive the message into
Résultat bool

XSend() protected méthode

Transmit the given message. The TrySend method calls this to do the actual sending. This abstract method gets overridden by the different socket types to provide their concrete implementation of sending messages.
protected XSend ( Msg &msg ) : bool
msg Msg the message to transmit
Résultat bool

XSetSocketOption() protected méthode

The default implementation assumes there are no specific socket options for the particular socket type. If not so, overload this method.
protected XSetSocketOption ( ZmqSocketOption option, [ optionValue ) : bool
option ZmqSocketOption a ZmqSocketOption specifying which option to set
optionValue [ an Object that is the value to set the option to
Résultat bool

XTerminated() protected abstract méthode

Abstract method that gets called to signal that the given pipe is to be removed from this socket. The concrete implementations of SocketBase override this to provide their own implementation of how to terminate the pipe.
protected abstract XTerminated ( [ pipe ) : void
pipe [ the Pipe that is being removed
Résultat void

XWriteActivated() protected méthode

Indicate the given pipe as being ready for writing to by this socket. This abstract method gets called by the WriteActivated method and gets overridden by the different sockets to provide their own concrete implementation.
protected XWriteActivated ( [ pipe ) : void
pipe [ the Pipe that is now becoming available for writing
Résultat void