BufferedSocket manages asynchronous communications via TCP/IP sockets and exposes events and methods that make it easier for application developers to reap the benefits of async. patterns with a simpler interface. This class is used internally by Munja.


The following tables list the members exposed by BufferedSocket.

Public Fields

  Name Description
Public field SendComplete Synchronisation object for async. send operations
Top

Protected Fields

  Name Description
Family field recvTimer Timer used to implement timeout on receiving data
Family field sendOffset Current send position within buffer
Family field sendTimer Timer used to implement timeout on sending data
Top

Public Properties

  Name Description
Public property BaseSocket The .NET socket that this socket wraps
Public property CanSend Is the socket ready to send more data?
Public property Closed Indicates whether the socket has been closed
Public property ReceiveBuffer Receive buffer
Public property ReceiveOffset Current position within receive buffer
Public property Receiving Internal use only
Public property SendBuffer Buffer for sending data
Public property Sending Indicates whether the socket is currently sending data
Public property SendMax Maximum bytes to send
Public property Tag User defined object to associate with socket
Public property TimedOut Set when a timeout occurs
Public property TotalBytesReceived Total bytes received through this socket
Public property TotalBytesSent Total bytes sent through this socket
Top

Public Methods

  Name Description
Public method AsyncSend Call this method to start sending data from the SendBuffer
Public method BeginReceive Overloaded. Call this method to begin receiving data from the socket
Public method BeginSend Call this method to send data asynchronously
Public method Equals Determines whether the specified Object is equal to the current Object. (inherited from Object)
Public method ExtractLineFromReceiveBuffer For text based protocols such as HTTP, SMTP, POP3 this method will extract a text line from the binary buffer.
Public method ExtractLinesFromReceiveBuffer Extracts text lines from a binary buffer until a blank line or the end of is encountered.
Public method GetHashCode Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table. (inherited from Object)
Public method GetType Gets the Type of the current instance. (inherited from Object)
Public method OnReceive Internal event handler for async. result which then fires DataReceived
Public method OnSend Handler for async. sending event. Will then fire SendCompleted when all the data in SendBuffer has been sent.
Public method Reset Resets the socket ready for (re)use
Public method ShiftReceiveBuffer Shifts the buffer after data has been extracted
Public method Shutdown Shuts down all communications on this socket
Public method SyncSend By default BufferedSocket uses the async. communications model but can be forced to send data synchronously by using this method.
Public method ToString Returns a String that represents the current Object. (inherited from Object)
Top

Protected Methods

  Name Description
Family method Finalize Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (inherited from Object)
Family method MemberwiseClone Creates a shallow copy of the current Object. (inherited from Object)
Family method TraceWriteLine Debug trace output
Top

Public Events

  Name Description
Public event DataReceived This event is fired when data is received on the socket
Public event SendCompleted This event is fired once all the data in the send buffer has been sent
Top

See Also