C# Class CrossroadsIO.SendReceiveExtensions

Defines extensions for Send/Receive methods in Socket.
显示文件 Open project: jgoz/crossroads-net

Public Methods

Method Description
Receive ( this socket, Encoding encoding ) : string

Receive a string message from a remote socket in blocking mode.

Receive ( this socket, Encoding encoding, System.TimeSpan timeout ) : string

Receive a string message from a remote socket in non-blocking mode with a specified timeout.

ReceiveFrame ( this socket ) : Frame

Receive a single frame from a remote socket in blocking mode.

This overload will allocate a new Frame for receiving all available data in the message-part.

ReceiveFrame ( this socket, Frame frame ) : Frame

Receive a single frame from a remote socket in blocking mode.

This overload will receive all available data in the message-part. If the buffer size of frame is insufficient, a new buffer will be allocated.

ReceiveFrame ( this socket, Frame frame, System.TimeSpan timeout ) : Frame

Receive a single frame from a remote socket in non-blocking mode with a specified timeout.

This overload will receive all available data in the message-part. If the buffer size of frame is insufficient, a new buffer will be allocated.

ReceiveFrame ( this socket, System.TimeSpan timeout ) : Frame

Receive a single frame from a remote socket in non-blocking mode with a specified timeout.

This overload will allocate a new Frame for receiving all available data in the message-part.

ReceiveMessage ( this socket ) : Message

Receive all parts of a multi-part message from a remote socket in blocking mode.

ReceiveMessage ( this socket, Message message ) : Message

Receive all parts of a multi-part message from a remote socket in blocking mode and append them to a given message.

ReceiveMessage ( this socket, Message message, System.TimeSpan frameTimeout ) : Message

Receive all parts of a multi-part message from a remote socket in non-blocking mode.

The frameTimeout will be used for each underlying Receive operation. If the timeout elapses before the last message is received, an incomplete message will be returned.

ReceiveMessage ( this socket, System.TimeSpan frameTimeout ) : Message

Receive all parts of a multi-part message from a remote socket in non-blocking mode.

The frameTimeout will be used for each underlying Receive operation. If the timeout elapses before the last message is received, an incomplete message will be returned. Use the ReceiveMessage(Socket,Message,System.TimeSpan) overload to continue appending message-parts if the returned Message has its Message.IsComplete property set to false.

Send ( this socket, byte buffer ) : SendStatus

Queue a single-part (or final multi-part) message buffer to be sent by the socket in blocking mode.

This method assumes that the message fills the entire buffer.

Send ( this socket, byte buffer, System.TimeSpan timeout ) : SendStatus

Queue a single-part (or final multi-part) message buffer to be sent by the socket in non-blocking mode with a specified timeout.

This method assumes that the message fills the entire buffer.

Send ( this socket, string message, Encoding encoding ) : SendStatus

Queue a single-part (or final multi-part) message string to be sent by the socket in blocking mode.

Send ( this socket, string message, Encoding encoding, System.TimeSpan timeout ) : SendStatus

Queue a single-part (or final multi-part) message string to be sent by the socket in non-blocking mode with a specified timeout.

SendFrame ( this socket, Frame frame ) : SendStatus

Queue a message frame to be sent by the socket in blocking mode.

The Frame.HasMore property on frame will be used to indicate whether more frames will follow in the current multi-part message sequence.

SendFrame ( this socket, Frame frame, System.TimeSpan timeout ) : SendStatus

Queue a message frame to be sent by the socket in non-blocking mode with a specified timeout.

The Frame.HasMore property on frame will be used to indicate whether more frames will follow in the current multi-part message sequence.

SendMessage ( this socket, Message message ) : SendStatus

Queue a multi-part message to be sent by the socket in blocking mode.

SendMore ( this socket, byte buffer ) : SendStatus

Queue a non-final message-part buffer to be sent by the socket in blocking mode.

This method assumes that the message fills the entire buffer. The final message-part in this series must be sent with Send(Socket,byte[]) or another overload that does not specify SocketFlags.SendMore.

SendMore ( this socket, byte buffer, System.TimeSpan timeout ) : SendStatus

Queue a non-final message-part buffer to be sent by the socket in non-blocking mode with a specified timeout.

This method assumes that the message fills the entire buffer. The final message-part in this series must be sent with Send(Socket,byte[],TimeSpan) or another overload that does not specify SocketFlags.SendMore.

SendMore ( this socket, string message, Encoding encoding ) : SendStatus

Queue a non-final message-part string to be sent by the socket in blocking mode.

SendMore ( this socket, string message, Encoding encoding, System.TimeSpan timeout ) : SendStatus

Queue a non-final message-part string to be sent by the socket in non-blocking mode with a specified timeout.

Private Methods

Method Description
SetFrameProperties ( Frame frame, Socket socket, int size ) : void
VerifyEncoding ( Encoding encoding ) : void
VerifyFrame ( Frame frame ) : void
VerifyMessage ( Message message ) : void
VerifySocket ( Socket socket ) : void
VerifyStringMessage ( string message ) : void

Method Details

Receive() public static method

Receive a string message from a remote socket in blocking mode.
is null. An error occurred receiving data from a remote endpoint. The has been closed. The current socket type does not support Receive operations.
public static Receive ( this socket, Encoding encoding ) : string
socket this A object.
encoding System.Text.Encoding The to use when converting the received buffer to a string.
return string

Receive() public static method

Receive a string message from a remote socket in non-blocking mode with a specified timeout.
is null. An error occurred receiving data from a remote endpoint. The has been closed. The current socket type does not support Receive operations.
public static Receive ( this socket, Encoding encoding, System.TimeSpan timeout ) : string
socket this A object.
encoding System.Text.Encoding The to use when converting the received buffer to a string.
timeout System.TimeSpan A specifying the receive timeout.
return string

ReceiveFrame() public static method

Receive a single frame from a remote socket in blocking mode.
This overload will allocate a new Frame for receiving all available data in the message-part.
An error occurred receiving data from a remote endpoint. The has been closed. The current socket type does not support Receive operations.
public static ReceiveFrame ( this socket ) : Frame
socket this A object.
return Frame

ReceiveFrame() public static method

Receive a single frame from a remote socket in blocking mode.
This overload will receive all available data in the message-part. If the buffer size of frame is insufficient, a new buffer will be allocated.
An error occurred receiving data from a remote endpoint. The has been closed. The current socket type does not support Receive operations.
public static ReceiveFrame ( this socket, Frame frame ) : Frame
socket this A object.
frame Frame A that will store the received data.
return Frame

ReceiveFrame() public static method

Receive a single frame from a remote socket in non-blocking mode with a specified timeout.
This overload will receive all available data in the message-part. If the buffer size of frame is insufficient, a new buffer will be allocated.
An error occurred receiving data from a remote endpoint. The has been closed. The current socket type does not support Receive operations.
public static ReceiveFrame ( this socket, Frame frame, System.TimeSpan timeout ) : Frame
socket this A object.
frame Frame A that will store the received data.
timeout System.TimeSpan A specifying the receive timeout.
return Frame

ReceiveFrame() public static method

Receive a single frame from a remote socket in non-blocking mode with a specified timeout.
This overload will allocate a new Frame for receiving all available data in the message-part.
An error occurred receiving data from a remote endpoint. The has been closed. The current socket type does not support Receive operations.
public static ReceiveFrame ( this socket, System.TimeSpan timeout ) : Frame
socket this A object.
timeout System.TimeSpan A specifying the receive timeout.
return Frame

ReceiveMessage() public static method

Receive all parts of a multi-part message from a remote socket in blocking mode.
An error occurred receiving data from a remote endpoint. The has been closed. The current socket type does not support Receive operations.
public static ReceiveMessage ( this socket ) : Message
socket this A object.
return Message

ReceiveMessage() public static method

Receive all parts of a multi-part message from a remote socket in blocking mode and append them to a given message.
is null. An error occurred receiving data from a remote endpoint. The has been closed. The current socket type does not support Receive operations.
public static ReceiveMessage ( this socket, Message message ) : Message
socket this A object.
message Message The to which message-parts will be appended.
return Message

ReceiveMessage() public static method

Receive all parts of a multi-part message from a remote socket in non-blocking mode.
The frameTimeout will be used for each underlying Receive operation. If the timeout elapses before the last message is received, an incomplete message will be returned.
An error occurred receiving data from a remote endpoint. The has been closed. The current socket type does not support Receive operations.
public static ReceiveMessage ( this socket, Message message, System.TimeSpan frameTimeout ) : Message
socket this A object.
message Message The to which message-parts will be appended.
frameTimeout System.TimeSpan A specifying the receive timeout for each frame.
return Message

ReceiveMessage() public static method

Receive all parts of a multi-part message from a remote socket in non-blocking mode.
The frameTimeout will be used for each underlying Receive operation. If the timeout elapses before the last message is received, an incomplete message will be returned. Use the ReceiveMessage(Socket,Message,System.TimeSpan) overload to continue appending message-parts if the returned Message has its Message.IsComplete property set to false.
An error occurred receiving data from a remote endpoint. The has been closed. The current socket type does not support Receive operations.
public static ReceiveMessage ( this socket, System.TimeSpan frameTimeout ) : Message
socket this A object.
frameTimeout System.TimeSpan A specifying the receive timeout for each frame.
return Message

Send() public static method

Queue a single-part (or final multi-part) message buffer to be sent by the socket in blocking mode.
This method assumes that the message fills the entire buffer.
is null. An error occurred sending data to a remote endpoint. The has been closed. The current socket type does not support Send operations.
public static Send ( this socket, byte buffer ) : SendStatus
socket this A object.
buffer byte A array that contains the message to be sent.
return SendStatus

Send() public static method

Queue a single-part (or final multi-part) message buffer to be sent by the socket in non-blocking mode with a specified timeout.
This method assumes that the message fills the entire buffer.
is null. An error occurred sending data to a remote endpoint. The has been closed. The current socket type does not support Send operations.
public static Send ( this socket, byte buffer, System.TimeSpan timeout ) : SendStatus
socket this A object.
buffer byte A array that contains the message to be sent.
timeout System.TimeSpan A specifying the send timeout.
return SendStatus

Send() public static method

Queue a single-part (or final multi-part) message string to be sent by the socket in blocking mode.
or is null. An error occurred sending data to a remote endpoint. The has been closed. The current socket type does not support Send operations.
public static Send ( this socket, string message, Encoding encoding ) : SendStatus
socket this A object.
message string A that contains the message to be sent.
encoding System.Text.Encoding The to use when converting to a buffer.
return SendStatus

Send() public static method

Queue a single-part (or final multi-part) message string to be sent by the socket in non-blocking mode with a specified timeout.
or is null. An error occurred sending data to a remote endpoint. The has been closed. The current socket type does not support Send operations.
public static Send ( this socket, string message, Encoding encoding, System.TimeSpan timeout ) : SendStatus
socket this A object.
message string A that contains the message to be sent.
encoding System.Text.Encoding The to use when converting to a buffer.
timeout System.TimeSpan A specifying the send timeout.
return SendStatus

SendFrame() public static method

Queue a message frame to be sent by the socket in blocking mode.
The Frame.HasMore property on frame will be used to indicate whether more frames will follow in the current multi-part message sequence.
is null. An error occurred sending data to a remote endpoint. The has been closed. The current socket type does not support Send operations.
public static SendFrame ( this socket, Frame frame ) : SendStatus
socket this A object.
frame Frame A that contains the message to be sent.
return SendStatus

SendFrame() public static method

Queue a message frame to be sent by the socket in non-blocking mode with a specified timeout.
The Frame.HasMore property on frame will be used to indicate whether more frames will follow in the current multi-part message sequence.
is null. An error occurred sending data to a remote endpoint. The has been closed. The current socket type does not support Send operations.
public static SendFrame ( this socket, Frame frame, System.TimeSpan timeout ) : SendStatus
socket this A object.
frame Frame A that contains the message to be sent.
timeout System.TimeSpan A specifying the send timeout.
return SendStatus

SendMessage() public static method

Queue a multi-part message to be sent by the socket in blocking mode.
is null. is incomplete. An error occurred sending data to a remote endpoint. The has been closed. The current socket type does not support Send operations.
public static SendMessage ( this socket, Message message ) : SendStatus
socket this A object.
message Message A that contains the message parts to be sent.
return SendStatus

SendMore() public static method

Queue a non-final message-part buffer to be sent by the socket in blocking mode.
This method assumes that the message fills the entire buffer. The final message-part in this series must be sent with Send(Socket,byte[]) or another overload that does not specify SocketFlags.SendMore.
is null. An error occurred sending data to a remote endpoint. The has been closed. The current socket type does not support Send operations.
public static SendMore ( this socket, byte buffer ) : SendStatus
socket this A object.
buffer byte A array that contains the message to be sent.
return SendStatus

SendMore() public static method

Queue a non-final message-part buffer to be sent by the socket in non-blocking mode with a specified timeout.
This method assumes that the message fills the entire buffer. The final message-part in this series must be sent with Send(Socket,byte[],TimeSpan) or another overload that does not specify SocketFlags.SendMore.
is null. An error occurred sending data to a remote endpoint. The has been closed. The current socket type does not support Send operations.
public static SendMore ( this socket, byte buffer, System.TimeSpan timeout ) : SendStatus
socket this A object.
buffer byte A array that contains the message to be sent.
timeout System.TimeSpan A specifying the send timeout.
return SendStatus

SendMore() public static method

Queue a non-final message-part string to be sent by the socket in blocking mode.
or is null. An error occurred sending data to a remote endpoint. The has been closed. The current socket type does not support Send operations.
public static SendMore ( this socket, string message, Encoding encoding ) : SendStatus
socket this A object.
message string A that contains the message to be sent.
encoding System.Text.Encoding The to use when converting to a buffer.
return SendStatus

SendMore() public static method

Queue a non-final message-part string to be sent by the socket in non-blocking mode with a specified timeout.
or is null. An error occurred sending data to a remote endpoint. The has been closed. The current socket type does not support Send operations.
public static SendMore ( this socket, string message, Encoding encoding, System.TimeSpan timeout ) : SendStatus
socket this A object.
message string A that contains the message to be sent.
encoding System.Text.Encoding The to use when converting to a buffer.
timeout System.TimeSpan A specifying the send timeout.
return SendStatus