本文整理汇总了C#中Socket.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Socket.GetType方法的具体用法?C# Socket.GetType怎么用?C# Socket.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Socket
的用法示例。
在下文中一共展示了Socket.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginAccept
public IAsyncResult BeginAccept (Socket acceptSocket,
int receiveSize,
AsyncCallback callback,
object state)
{
if (disposed && closed)
throw new ObjectDisposedException (GetType ().ToString ());
if (receiveSize < 0)
throw new ArgumentOutOfRangeException ("receiveSize", "receiveSize is less than zero");
if (acceptSocket != null) {
if (acceptSocket.disposed && acceptSocket.closed)
throw new ObjectDisposedException (acceptSocket.GetType ().ToString ());
if (acceptSocket.IsBound)
throw new InvalidOperationException ();
/* For some reason the MS runtime
* barfs if the new socket is not TCP,
* even though it's just about to blow
* away all those parameters
*/
if (acceptSocket.ProtocolType != ProtocolType.Tcp)
throw new SocketException ((int)SocketError.InvalidArgument);
}
SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.AcceptReceive);
req.Buffer = new byte[receiveSize];
req.Offset = 0;
req.Size = receiveSize;
req.SockFlags = SocketFlags.None;
req.AcceptSocket = acceptSocket;
int count;
lock (readQ) {
readQ.Enqueue (req.Worker);
count = readQ.Count;
}
if (count == 1)
socket_pool_queue (Worker.Dispatcher, req);
return(req);
}
示例2: ThrowIfDisposedAndClosed
void ThrowIfDisposedAndClosed (Socket socket)
{
if (socket.is_disposed && socket.is_closed)
throw new ObjectDisposedException (socket.GetType ().ToString ());
}
示例3: Attach
/// <summary>
/// Attach this AsyncSocket to an existing Socket
/// </summary>
/// <param name="UseThisSocket">The Socket</param>
public void Attach(Socket UseThisSocket)
{
endpoint_local = (IPEndPoint)UseThisSocket.LocalEndPoint;
TotalBytesSent = 0;
LocalEP = UseThisSocket.LocalEndPoint;
if (UseThisSocket.SocketType == SocketType.Stream)
{
RemoteEP = UseThisSocket.RemoteEndPoint;
endpoint_local = (IPEndPoint)UseThisSocket.LocalEndPoint;
}
else
{
RemoteEP = null;
}
MainSocket = UseThisSocket;
System.Reflection.PropertyInfo pi = MainSocket.GetType().GetProperty("UseOnlyOverlappedIO");
if (pi != null)
{
pi.SetValue(MainSocket, true, null);
}
Init();
}