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


C# SocketAsyncEventArgs.DoOperation方法代码示例

本文整理汇总了C#中System.Net.Sockets.SocketAsyncEventArgs.DoOperation方法的典型用法代码示例。如果您正苦于以下问题:C# SocketAsyncEventArgs.DoOperation方法的具体用法?C# SocketAsyncEventArgs.DoOperation怎么用?C# SocketAsyncEventArgs.DoOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Sockets.SocketAsyncEventArgs的用法示例。


在下文中一共展示了SocketAsyncEventArgs.DoOperation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConnectAsync

		public bool ConnectAsync (SocketAsyncEventArgs e)
		{
			if (disposed && closed)
				throw new ObjectDisposedException (GetType ().ToString ());

			CheckConnect (e);
			// if an address family is specified then they must match
			AddressFamily raf = e.RemoteEndPoint.AddressFamily;
			if ((raf != AddressFamily.Unspecified) && (raf != AddressFamily))
				throw new NotSupportedException ("AddressFamily mismatch between socket and endpoint");

			e.DoOperation (SocketAsyncOperation.Connect, this);

			// We always return true for now
			return true;
		}
开发者ID:telurmasin,项目名称:mono,代码行数:16,代码来源:Socket_2_1.cs

示例2: ReceiveFromAsync

		public bool ReceiveFromAsync (SocketAsyncEventArgs e)
		{
			if (disposed && closed)
				throw new ObjectDisposedException (GetType ().ToString ());

			// We do not support recv into multiple buffers yet
			if (e.BufferList != null)
				throw new NotSupportedException ("Mono doesn't support using BufferList at this point.");
			if (e.RemoteEndPoint == null)
				throw new ArgumentNullException ("remoteEP", "Value cannot be null.");

			e.DoOperation (SocketAsyncOperation.ReceiveFrom, this);

			// We always return true for now
			return true;
		}
开发者ID:tgiphil,项目名称:Mono-Class-Libraries,代码行数:16,代码来源:Socket.cs

示例3: SendToAsync

		public bool SendToAsync (SocketAsyncEventArgs e)
		{
			// NO check is made whether e != null in MS.NET (NRE is thrown in such case)
			
			if (disposed && closed)
				throw new ObjectDisposedException (GetType ().ToString ());
			if (e.RemoteEndPoint == null)
				throw new ArgumentNullException ("remoteEP", "Value cannot be null.");
			
			e.DoOperation (SocketAsyncOperation.SendTo, this);

			// We always return true for now
			return true;
		}
开发者ID:tgiphil,项目名称:Mono-Class-Libraries,代码行数:14,代码来源:Socket.cs

示例4: ConnectAsync

		public bool ConnectAsync (SocketAsyncEventArgs e)
		{
			// NO check is made whether e != null in MS.NET (NRE is thrown in such case)
			
			if (disposed && closed)
				throw new ObjectDisposedException (GetType ().ToString ());
			if (islistening)
				throw new InvalidOperationException ("You may not perform this operation after calling the Listen method.");
			if (e.RemoteEndPoint == null)
				throw new ArgumentNullException ("remoteEP", "Value cannot be null.");
			if (e.BufferList != null)
				throw new ArgumentException ("Multiple buffers cannot be used with this method.");

			e.DoOperation (SocketAsyncOperation.Connect, this);

			// We always return true for now
			return true;
		}
开发者ID:tgiphil,项目名称:Mono-Class-Libraries,代码行数:18,代码来源:Socket.cs

示例5: DisconnectAsync

		public bool DisconnectAsync (SocketAsyncEventArgs e)
		{
			// NO check is made whether e != null in MS.NET (NRE is thrown in such case)
			if (disposed && closed)
				throw new ObjectDisposedException (GetType ().ToString ());

			e.DoOperation (SocketAsyncOperation.Disconnect, this);

			return true;
		}
开发者ID:tgiphil,项目名称:Mono-Class-Libraries,代码行数:10,代码来源:Socket.cs

示例6: AcceptAsync

		public bool AcceptAsync (SocketAsyncEventArgs e)
		{
			// NO check is made whether e != null in MS.NET (NRE is thrown in such case)
			
			if (disposed && closed)
				throw new ObjectDisposedException (GetType ().ToString ());
			if (!IsBound)
				throw new InvalidOperationException ("You must call the Bind method before performing this operation.");
			if (!islistening)
				throw new InvalidOperationException ("You must call the Listen method before performing this operation.");
			if (e.BufferList != null)
				throw new ArgumentException ("Multiple buffers cannot be used with this method.");
			if (e.Count < 0)
				throw new ArgumentOutOfRangeException ("e.Count");
			
			Socket acceptSocket = e.AcceptSocket;
			if (acceptSocket != null) {
				if (acceptSocket.IsBound || acceptSocket.Connected)
					throw new InvalidOperationException ("AcceptSocket: The socket must not be bound or connected.");
			} else
				e.AcceptSocket = new Socket (AddressFamily, SocketType, ProtocolType);

			try {
				e.DoOperation (SocketAsyncOperation.Accept, this);
			} catch {
				((IDisposable)e).Dispose ();
				throw;
			}

			// We always return true for now
			return true;
		}
开发者ID:tgiphil,项目名称:Mono-Class-Libraries,代码行数:32,代码来源:Socket.cs

示例7: SendAsync

		public bool SendAsync (SocketAsyncEventArgs e)
		{
			// NO check is made whether e != null in MS.NET (NRE is thrown in such case)
			
			if (disposed && closed)
				throw new ObjectDisposedException (GetType ().ToString ());
			if (e.Buffer == null && e.BufferList == null)
				throw new ArgumentException ("Either e.Buffer or e.BufferList must be valid buffers.");

			e.DoOperation (SocketAsyncOperation.Send, this);

			// We always return true for now
			return true;
		}
开发者ID:alisci01,项目名称:mono,代码行数:14,代码来源:Socket_2_1.cs

示例8: ReceiveAsync

		public bool ReceiveAsync (SocketAsyncEventArgs e)
		{
			// NO check is made whether e != null in MS.NET (NRE is thrown in such case)
			//
			// LAME SPEC: the ArgumentException is never thrown, instead an NRE is
			// thrown when e.Buffer and e.BufferList are null (works fine when one is
			// set to a valid object)
			if (disposed && closed)
				throw new ObjectDisposedException (GetType ().ToString ());

			// We do not support recv into multiple buffers yet
			if (e.BufferList != null)
				throw new NotSupportedException ("Mono doesn't support using BufferList at this point.");
			
			e.DoOperation (SocketAsyncOperation.Receive, this);

			// We always return true for now
			return true;
		}
开发者ID:alisci01,项目名称:mono,代码行数:19,代码来源:Socket_2_1.cs

示例9: ConnectAsync

		public static bool ConnectAsync (SocketType socketType, ProtocolType protocolType, SocketAsyncEventArgs e)
		{
			// exception ordering requires to check before creating the socket (good thing resource wise too)
			CheckConnect (e);

			Socket s = new Socket (AddressFamily.InterNetwork, socketType, protocolType);
			e.DoOperation (SocketAsyncOperation.Connect, s);

			// We always return true for now
			return true;
		}
开发者ID:stabbylambda,项目名称:mono,代码行数:11,代码来源:Socket_2_1.cs


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