C# Класс P2PStateServer.ServiceSocket

Represents an exception-safe wrapper of the .NET socket class. It exposes asynchronous methods and properties useful for state server soket operations.
The .NET Socket class is thread-safe but you can never be too careful. This class introduces an extra synchronization layer.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Abort ( ) : void

Terminates a connection

BeginConnect ( string Host, int Port, AsyncCallback ConnectCallBack, object StateObject ) : IAsyncResult

Begins an asynchronous Connect

BeginReceive ( int BufferLength, AsyncCallback ReadCallBack, object StateObject ) : IAsyncResult

Begins an asynchronous receive

CheckConnection ( ) : bool

Returns a value which indicates whether the socket is still connected.

This method actively checks the connection status by sending a zero-sized payload packet to inbound sockets or calling Socket.Poll for outbound sockets.

Close ( ) : void

Closes the socket gracefully

EndConnect ( IAsyncResult ar ) : void

Ends an asynchronous Connect

EndReceive ( IAsyncResult ar, bool &Error ) : byte[]

Ends an asynchronous Receive

Equals ( object obj ) : bool
GetHashCode ( ) : int
Listen ( int Port, AsyncCallback AcceptCallback ) : Socket

Listens on a specified port on the machine

Send ( ResponseData Message ) : void

Sends data via the socket asynchronously

ServiceSocket ( Socket socket, bool IsPeerSocket, IBufferPool Buffers ) : System

Initializes a new instance of the ServiceSocket class.

ServiceSocket ( bool IsPeerSocket, IBufferPool Buffers ) : System

Initializes a new instance of the ServiceSocket class.

Приватные методы

Метод Описание
CompleteSend ( IAsyncResult ar ) : void

Completes an asynchronous send

ServiceSocket ( ) : System

Описание методов

Abort() публичный Метод

Terminates a connection
public Abort ( ) : void
Результат void

BeginConnect() публичный Метод

Begins an asynchronous Connect
public BeginConnect ( string Host, int Port, AsyncCallback ConnectCallBack, object StateObject ) : IAsyncResult
Host string Host to connect to
Port int Port number to connect to
ConnectCallBack AsyncCallback Callback to call on connecting
StateObject object State object to pass to ConnectCallback
Результат IAsyncResult

BeginReceive() публичный Метод

Begins an asynchronous receive
public BeginReceive ( int BufferLength, AsyncCallback ReadCallBack, object StateObject ) : IAsyncResult
BufferLength int
ReadCallBack AsyncCallback Method to call on receiving data
StateObject object State object to be passed to ReadCallBack
Результат IAsyncResult

CheckConnection() публичный Метод

Returns a value which indicates whether the socket is still connected.
This method actively checks the connection status by sending a zero-sized payload packet to inbound sockets or calling Socket.Poll for outbound sockets.
public CheckConnection ( ) : bool
Результат bool

Close() публичный Метод

Closes the socket gracefully
public Close ( ) : void
Результат void

EndConnect() публичный Метод

Ends an asynchronous Connect
public EndConnect ( IAsyncResult ar ) : void
ar IAsyncResult AsyncResult obtained from BeginConnect
Результат void

EndReceive() публичный Метод

Ends an asynchronous Receive
public EndReceive ( IAsyncResult ar, bool &Error ) : byte[]
ar IAsyncResult AsyncResult obtained from BeginReive
Error bool Indicates an error occured while receiving data
Результат byte[]

Equals() публичный Метод

public Equals ( object obj ) : bool
obj object
Результат bool

GetHashCode() публичный Метод

public GetHashCode ( ) : int
Результат int

Listen() публичный статический Метод

Listens on a specified port on the machine
public static Listen ( int Port, AsyncCallback AcceptCallback ) : Socket
Port int Port number
AcceptCallback AsyncCallback Callback for accepting new connections
Результат Socket

Send() публичный Метод

Sends data via the socket asynchronously
public Send ( ResponseData Message ) : void
Message ResponseData Data to transmit
Результат void

ServiceSocket() публичный Метод

Initializes a new instance of the ServiceSocket class.
public ServiceSocket ( Socket socket, bool IsPeerSocket, IBufferPool Buffers ) : System
socket Socket The .NET Socket object to encapsulate
IsPeerSocket bool Indicates if this socket was spawned from the state server peer port
Buffers IBufferPool
Результат System

ServiceSocket() публичный Метод

Initializes a new instance of the ServiceSocket class.
public ServiceSocket ( bool IsPeerSocket, IBufferPool Buffers ) : System
IsPeerSocket bool Indicates if this socket was spawned from the state server peer port
Buffers IBufferPool
Результат System