本文整理汇总了C#中Socket.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Socket.Equals方法的具体用法?C# Socket.Equals怎么用?C# Socket.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Socket
的用法示例。
在下文中一共展示了Socket.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send
public override void Send(string message, Socket source, bool SendOnly)
{
Byte[] msg = Encoding.UTF8.GetBytes(message);
if (!SendOnly)
{
foreach (Socket communicateSocket in communicateSockets)
{
try
{
if (source == null || !source.Equals(communicateSocket))
{
communicateSocket.BeginSend(msg, 0, msg.Length, SocketFlags.None,
ar =>
{
}, null);
}
}
catch
{
NumberToShutdown = communicateSockets.IndexOf(communicateSocket);
}
}
}
else
{
try
{
source.BeginSend(msg, 0, msg.Length, SocketFlags.None,
ar =>
{
}, null);
}
catch
{
NumberToShutdown = communicateSockets.IndexOf(source);
}
}
}
示例2: set_fd
/// <summary>
/// Set Socket for TLS connection
/// </summary>
/// <param name="ssl">structure to set Socket in</param>
/// <param name="fd">Socket to use</param>
/// <returns>1 on success</returns>
public static int set_fd(IntPtr ssl, Socket fd)
{
/* sanity check on inputs */
if (ssl == IntPtr.Zero)
{
return FAILURE;
}
try
{
if (!fd.Equals(null))
{
GCHandle gch = GCHandle.FromIntPtr(ssl);
ctx_handles handles = (ctx_handles)gch.Target;
IntPtr sslCtx = handles.get_ctx();
IntPtr ptr;
GCHandle fd_pin = GCHandle.Alloc(fd);
if (sslCtx == IntPtr.Zero)
{
log(ERROR_LOG, "wolfssl error setting up fd!!");
return FAILURE;
}
handles.set_fd(fd_pin);
ptr = GCHandle.ToIntPtr(fd_pin);
wolfSSL_SetIOWriteCtx(sslCtx, ptr); //pass along the socket for writing to
wolfSSL_SetIOReadCtx(sslCtx, ptr); //pass along the socket for reading from
return SUCCESS;
}
return FAILURE;
}
catch (Exception e)
{
log(ERROR_LOG, "Error setting up fd!! " + e.ToString());
return FAILURE;
}
}
示例3: SendMessage
public void SendMessage(string message, Socket exceptThisSocket)
{
String validMessage = String.Format("#0#{0}##", message);
foreach (Socket socket in this.ClientSendData)
{
if (exceptThisSocket.Equals(socket))
{
continue;
}
socket.Send(Encoding.UTF8.GetBytes(validMessage), SocketFlags.None);
}
}