C# 클래스 NetMQ.Core.SocketBase

상속: NetMQ.Core.Own, IPollEvents, Pipe.IPipeEvents
파일 보기 프로젝트 열기: NetMQ/NetMQ3-x 1 사용 예제들

Private Properties

프로퍼티 타입 설명
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

공개 메소드들

메소드 설명
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.

보호된 메소드들

메소드 설명
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.

비공개 메소드들

메소드 설명
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.

메소드 상세

Bind() 공개 메소드

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
리턴 void

BindRandomPort() 공개 메소드

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
리턴 int

CheckDisposed() 공개 메소드

Throw ObjectDisposedException if this socket is already disposed.
This object is already disposed.
public CheckDisposed ( ) : void
리턴 void

Close() 공개 메소드

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
리턴 void

Connect() 공개 메소드

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
리턴 void

Destroy() 공개 메소드

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
리턴 void

EventAcceptFailed() 공개 메소드

public EventAcceptFailed ( [ addr, ErrorCode errno ) : void
addr [
errno ErrorCode
리턴 void

EventAccepted() 공개 메소드

public EventAccepted ( [ addr, [ ch ) : void
addr [
ch [
리턴 void

EventBindFailed() 공개 메소드

public EventBindFailed ( [ addr, ErrorCode errno ) : void
addr [
errno ErrorCode
리턴 void

EventCloseFailed() 공개 메소드

public EventCloseFailed ( [ addr, ErrorCode errno ) : void
addr [
errno ErrorCode
리턴 void

EventClosed() 공개 메소드

public EventClosed ( [ addr, [ ch ) : void
addr [
ch [
리턴 void

EventConnectDelayed() 공개 메소드

public EventConnectDelayed ( [ addr, ErrorCode errno ) : void
addr [
errno ErrorCode
리턴 void

EventConnectRetried() 공개 메소드

public EventConnectRetried ( [ addr, int interval ) : void
addr [
interval int
리턴 void

EventConnected() 공개 메소드

public EventConnected ( [ addr, [ ch ) : void
addr [
ch [
리턴 void

EventDisconnected() 공개 메소드

public EventDisconnected ( [ addr, [ ch ) : void
addr [
ch [
리턴 void

EventListening() 공개 메소드

public EventListening ( [ addr, [ ch ) : void
addr [
ch [
리턴 void

GetSocketOption() 공개 메소드

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
리턴 int

GetSocketOptionX() 공개 메소드

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
리턴 object

HasIn() 공개 메소드

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

HasOut() 공개 메소드

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

Hiccuped() 공개 메소드

public Hiccuped ( NetMQ.Core.Pipe pipe ) : void
pipe NetMQ.Core.Pipe
리턴 void

InEvent() 공개 메소드

Handle input-ready events by receiving and processing any incoming commands.
public InEvent ( ) : void
리턴 void

Monitor() 공개 메소드

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
리턴 void

OutEvent() 공개 메소드

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

ProcessBind() 보호된 메소드

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

ProcessDestroy() 보호된 메소드

Mark this socket as having been destroyed. Delay actual destruction of the socket.
protected ProcessDestroy ( ) : void
리턴 void

ProcessStop() 보호된 메소드

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

ProcessTerm() 보호된 메소드

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.
리턴 void

ReadActivated() 공개 메소드

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
리턴 void

SetSocketOption() 공개 메소드

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
리턴 void

SocketBase() 보호된 메소드

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
리턴 System

Stop() 공개 메소드

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

TermEndpoint() 공개 메소드

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
리턴 void

Terminated() 공개 메소드

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
리턴 void

TimerEvent() 공개 메소드

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
리턴 void

ToString() 공개 메소드

Override the ToString method in order to also show the socket-id.
public ToString ( ) : string
리턴 string

TryRecv() 공개 메소드

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.
리턴 bool

TrySend() 공개 메소드

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.
리턴 bool

WriteActivated() 공개 메소드

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
리턴 void

XAttachPipe() 보호된 추상적인 메소드

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
리턴 void

XHasIn() 보호된 메소드

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

XHasOut() 보호된 메소드

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

XHiccuped() 보호된 메소드

protected XHiccuped ( [ pipe ) : void
pipe [
리턴 void

XReadActivated() 보호된 메소드

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
리턴 void

XRecv() 보호된 메소드

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
리턴 bool

XSend() 보호된 메소드

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
리턴 bool

XSetSocketOption() 보호된 메소드

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
리턴 bool

XTerminated() 보호된 추상적인 메소드

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
리턴 void

XWriteActivated() 보호된 메소드

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
리턴 void