当前位置: 首页>>代码示例>>C#>>正文


C# Socket.GetType方法代码示例

本文整理汇总了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);
		}
开发者ID:frje,项目名称:SharpLang,代码行数:42,代码来源:Socket.cs

示例2: ThrowIfDisposedAndClosed

		void ThrowIfDisposedAndClosed (Socket socket)
		{
			if (socket.is_disposed && socket.is_closed)
				throw new ObjectDisposedException (socket.GetType ().ToString ());
		}
开发者ID:Profit0004,项目名称:mono,代码行数:5,代码来源:Socket.cs

示例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();
 }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:26,代码来源:AsyncSocket.cs


注:本文中的Socket.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。