本文整理汇总了C#中SocketError类的典型用法代码示例。如果您正苦于以下问题:C# SocketError类的具体用法?C# SocketError怎么用?C# SocketError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SocketError类属于命名空间,在下文中一共展示了SocketError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReceiveChunk
public unsafe void ReceiveChunk(string endpoint, bool isAlive, int bytesReceived, SocketError status)
{
if (IsEnabled())
{
fixed (char* pEndpoint = endpoint)
{
var data = stackalloc EventData[4];
data[0].DataPointer = (IntPtr)(pEndpoint);
data[0].Size = (endpoint.Length + 1) * 2;
var alive = isAlive ? 1 : 0;
data[1].DataPointer = (IntPtr)(&alive);
data[1].Size = sizeof(int);
data[2].DataPointer = (IntPtr)(&bytesReceived);
data[2].Size = sizeof(int);
data[3].Size = sizeof(int);
data[3].DataPointer = (IntPtr)(&status);
WriteEventCore(22, 4, data);
}
}
}
示例2: InitOption
private void InitOption(MailStatus status, MailCause cause)
{
this.mStatus = status;
this.mCause = cause;
this.mSocketErrorCode = 0;
this.mSocketErrorCodeType = SocketError.Success;
}
示例3: OnConnectionFailed
private void OnConnectionFailed(ITcpConnection connection, SocketError socketError)
{
if (Interlocked.CompareExchange(ref _isClosed, 1, 0) == 0)
{
Console.WriteLine("Connection '{0}' ({1:B}) to [{2}] failed: {3}.", _connectionName, _connectionId, connection.RemoteEndPoint, socketError);
}
}
示例4: InCompleted
public void InCompleted(SocketError socketError, int bytesTransferred)
{
if (socketError != SocketError.Success)
{
m_socket.EventAcceptFailed(m_address.ToString(), ErrorHelper.SocketErrorToErrorCode(socketError));
// dispose old object
m_acceptedSocket.Handle.Dispose();
Accept();
}
else
{
m_acceptedSocket.InitOptions();
var pgmSession = new PgmSession(m_acceptedSocket, m_options);
IOThread ioThread = ChooseIOThread(m_options.Affinity);
SessionBase session = SessionBase.Create(ioThread, false, m_socket, m_options, new Address(m_handle.LocalEndPoint));
session.IncSeqnum();
LaunchChild(session);
SendAttach(session, pgmSession, false);
m_socket.EventAccepted(m_address.ToString(), m_acceptedSocket.Handle);
Accept();
}
}
示例5: OnClientDisconnect
private void OnClientDisconnect(ServerClient arg1, SocketError arg2)
{
Console.WriteLine("Disconnected");
_timeSyncCompleted = false;
_completedEvent.Set();
_batchCounter = 0;
}
示例6: OnConnectionClosed
private void OnConnectionClosed(ITcpConnection connection, SocketError socketError)
{
if (Interlocked.CompareExchange(ref _isClosed, 1, 0) == 0)
{
Console.WriteLine("Connection '{0}' [{1:B}] closed: {2}.", connection.ConnectionId, connection.RemoteEndPoint, socketError);
}
}
示例7: Connect
/// <summary>
/// Connect TCP socket to a server.
/// </summary>
/// <param name="serverAddr">IP or hostname of server.</param>
/// <param name="port">Port that TCP should use.</param>
/// <returns>True if connection is successful otherwise false</returns>
internal bool Connect(string serverAddr, int port)
{
try
{
IPAddress[] serverIP = Dns.GetHostAddresses(serverAddr);
if (serverIP.Length <= 0)
{
mErrorString = "Error looking up host name";
return false;
}
mTCPClient = new TcpClient();
mTCPClient.Connect(serverIP[0], port);
// Disable Nagle's algorithm
mTCPClient.NoDelay = true;
}
catch (SocketException e)
{
mErrorString = e.Message;
mErrorCode = e.SocketErrorCode;
if (mTCPClient != null)
{
mTCPClient.Close();
}
return false;
}
return true;
}
示例8: CheckAsyncCallOverlappedResult
internal SocketError CheckAsyncCallOverlappedResult(SocketError errorCode)
{
if (this.m_UseOverlappedIO)
{
switch (errorCode)
{
case SocketError.Success:
case SocketError.IOPending:
ThreadPool.UnsafeRegisterWaitForSingleObject(this.m_OverlappedEvent, new WaitOrTimerCallback(this.OverlappedCallback), this, -1, true);
return SocketError.Success;
}
base.ErrorCode = (int) errorCode;
base.Result = -1;
this.ReleaseUnmanagedStructures();
return errorCode;
}
this.ReleaseUnmanagedStructures();
switch (errorCode)
{
case SocketError.Success:
case SocketError.IOPending:
return SocketError.Success;
}
base.ErrorCode = (int) errorCode;
base.Result = -1;
if (this.m_Cache != null)
{
this.m_Cache.Overlapped.AsyncResult = null;
}
this.ReleaseUnmanagedStructures();
return errorCode;
}
示例9: OnConnectionClosed
private void OnConnectionClosed(ITcpConnection connection, SocketError socketError)
{
connection.ConnectionClosed -= OnConnectionClosed;
var handler = ConnectionClosed;
if (handler != null)
handler(this, socketError);
}
示例10: AcceptCompletionCallback
private void AcceptCompletionCallback(IntPtr acceptedFileDescriptor, byte[] socketAddress, int socketAddressSize, SocketError socketError)
{
_acceptedFileDescriptor = acceptedFileDescriptor;
Debug.Assert(socketAddress == null || socketAddress == _acceptBuffer, $"Unexpected socketAddress: {socketAddress}");
_acceptAddressBufferCount = socketAddressSize;
CompletionCallback(0, socketError);
}
示例11: SocketException
internal SocketException(SocketError errorCode, uint platformError) : base((int)platformError)
{
_errorCode = errorCode;
if (GlobalLog.IsEnabled)
{
GlobalLog.Print($"SocketException::.ctor(SocketError={errorCode}, uint={platformError}):{Message}");
}
}
示例12: SocketException
/// <summary>Creates a new instance of the <see cref='System.Net.Sockets.SocketException'/> class with the specified error code as SocketError.</summary>
internal SocketException(SocketError socketError) : base(GetNativeErrorForSocketError(socketError))
{
_errorCode = socketError;
if (GlobalLog.IsEnabled)
{
GlobalLog.Print($"SocketException::.ctor(SocketError={socketError}):{Message}");
}
}
示例13: Close
public override bool Close () {
try {
socket.Close();
return true;
} catch (SocketException exn) {
socketError = exn.SocketErrorCode;
return false;
}
}
示例14: CompletionStatus
internal CompletionStatus(AsyncSocket asyncSocket, object state, OperationType operationType, SocketError socketError, int bytesTransferred) :
this()
{
AsyncSocket = asyncSocket;
State = state;
OperationType = operationType;
SocketError = socketError;
BytesTransferred = bytesTransferred;
}
示例15: CompletionCallback
public void CompletionCallback(int numBytes, byte[] socketAddress, int socketAddressSize, SocketFlags receivedFlags, SocketError errorCode)
{
if (_socketAddress != null)
{
Debug.Assert(socketAddress == null || _socketAddress.Buffer == socketAddress);
_socketAddressSize = socketAddressSize;
}
base.CompletionCallback(numBytes, errorCode);
}