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


C# SocketOperation类代码示例

本文整理汇总了C#中SocketOperation的典型用法代码示例。如果您正苦于以下问题:C# SocketOperation类的具体用法?C# SocketOperation怎么用?C# SocketOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Init

		public void Init (Socket socket, AsyncCallback callback, object state, SocketOperation operation)
		{
			base.Init (callback, state);

			this.socket = socket;
			this.handle = socket != null ? socket.Handle : IntPtr.Zero;
			this.operation = operation;

			DelayedException = null;

			EndPoint = null;
			Buffer = null;
			Offset = 0;
			Size = 0;
			SockFlags = SocketFlags.None;
			AcceptSocket = null;
			Addresses = null;
			Port = 0;
			Buffers = null;
			ReuseSocket = false;
			CurrentAddress = 0;

			AcceptedSocket = null;
			Total = 0;

			error = 0;

			EndCalled = 0;
		}
开发者ID:nickolyamba,项目名称:mono,代码行数:29,代码来源:SocketAsyncResult.cs

示例2: OnError

        static HandleResult OnError(TcpClient sender, SocketOperation enOperation, int errorCode)
        {
            // 出错了

            AddMsg(string.Format(" > [{0},OnError] -> OP:{1},CODE:{2}", sender.ConnectionId, enOperation, errorCode));

            // 通知界面,只处理了连接错误,也没进行是不是连接错误的判断,所以有错误就会设置界面
            // 生产环境请自己控制
            //this.Invoke(new SetAppStateDelegate(SetAppState), AppState.Stoped);

            return HandleResult.Ok;
        }
开发者ID:JerryXia,项目名称:MyWebDevTools,代码行数:12,代码来源:Program.cs

示例3: AssertCounter

		private void AssertCounter(SocketOperation operation, Func<MockServerSocket4, long> delegatingRetriever, Func<PerformanceCounter> counterRetriever, int expectedCount)
		{
			MockServerSocket4 mockServerSocket = new MockServerSocket4();
			IServerSocket4 serverSocket = new MonitoredServerSocket4(mockServerSocket);

			FileSession().WithEnvironment(
				delegate
					{
						IList<ISocket4> clients = new List<ISocket4>();
						for (int i = 0; i < ClientCount; i++)
						{
							clients.Add(serverSocket.Accept());
						}

						for (int i = 0; i < clients.Count; i++)
						{
							operation(clients[i], i);
						}
					});

			Assert.AreEqual(expectedCount, delegatingRetriever(mockServerSocket));
			Assert.AreEqual(expectedCount, counterRetriever().RawValue);
		}
开发者ID:erdincay,项目名称:db4o,代码行数:23,代码来源:ServerNetworkingPerformanceCounterTestCase.cs

示例4: OnError

 HandleResult OnError(TcpClient sender, SocketOperation enOperation, int errorCode)
 {
     // 出错了
     return HandleResult.Ok;
 }
开发者ID:andy521,项目名称:HP-Socket,代码行数:5,代码来源:frmClient.cs

示例5: InitSocketAsyncEventArgs

		void InitSocketAsyncEventArgs (SocketAsyncEventArgs e, AsyncCallback callback, object state, SocketOperation operation)
		{
			e.socket_async_result.Init (this, callback, state, operation);

			e.current_socket = this;
			e.SetLastOperation (SocketOperationToSocketAsyncOperation (operation));
			e.SocketError = SocketError.Success;
			e.BytesTransferred = 0;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:Socket.cs

示例6: Init

			/* This is called when reusing a SocketAsyncEventArgs */
			public void Init (Socket sock, object state, AsyncCallback callback, SocketOperation op)
			{
				result.Init (sock, state, callback, op);
				SocketAsyncOperation async_op;

				// Notes;
				// 	-SocketOperation.AcceptReceive not used in SocketAsyncEventArgs
				//	-SendPackets and ReceiveMessageFrom are not implemented yet
				if (op == Socket.SocketOperation.Connect)
					async_op = SocketAsyncOperation.Connect;
#if !MOONLIGHT
				else if (op == Socket.SocketOperation.Accept)
					async_op = SocketAsyncOperation.Accept;
				else if (op == Socket.SocketOperation.Disconnect)
					async_op = SocketAsyncOperation.Disconnect;
#endif
				else if (op == Socket.SocketOperation.Receive || op == Socket.SocketOperation.ReceiveGeneric)
					async_op = SocketAsyncOperation.Receive;
#if !MOONLIGHT
				else if (op == Socket.SocketOperation.ReceiveFrom)
					async_op = SocketAsyncOperation.ReceiveFrom;
#endif
				/*
				else if (op == Socket.SocketOperation.ReceiveMessageFrom)
					async_op = SocketAsyncOperation.ReceiveMessageFrom;
				*/
				else if (op == Socket.SocketOperation.Send || op == Socket.SocketOperation.SendGeneric)
					async_op = SocketAsyncOperation.Send;
#if !MOONLIGHT
				/*
				else if (op == Socket.SocketOperation.SendPackets)
					async_op = SocketAsyncOperation.SendPackets;
				*/
				else if (op == Socket.SocketOperation.SendTo)
					async_op = SocketAsyncOperation.SendTo;
#endif
				else
					throw new NotImplementedException (String.Format ("Operation {0} is not implemented", op));

				args.SetLastOperation (async_op);
				args.SocketError = SocketError.Success;
			}
开发者ID:telurmasin,项目名称:mono,代码行数:43,代码来源:Socket_2_1.cs

示例7: SocketAsyncResult

			public SocketAsyncResult (Socket sock, object state, AsyncCallback callback, SocketOperation operation)
			{
				this.Sock = sock;
				this.blocking = sock.blocking;
				this.handle = sock.socket;
				this.state = state;
				this.callback = callback;
				this.operation = operation;
				SockFlags = SocketFlags.None;
			}
开发者ID:telurmasin,项目名称:mono,代码行数:10,代码来源:Socket_2_1.cs

示例8: SocketAsyncResult

		public SocketAsyncResult (Socket socket, object state, AsyncCallback callback, SocketOperation operation)
		{
			Init (socket, state, callback, operation, new SocketAsyncWorker (this));
		}
开发者ID:quarksbar,项目名称:mono,代码行数:4,代码来源:SocketAsyncResult.cs

示例9: OnClose

        HandleResult OnClose(IntPtr connId, SocketOperation enOperation, int errorCode)
        {
            if(errorCode == 0)
                // 客户离开了
                AddMsg(string.Format(" > [{0},OnClose]", connId));
            else
                // 客户出错了
                AddMsg(string.Format(" > [{0},OnError] -> OP:{1},CODE:{2}", connId, enOperation, errorCode));
            // return HPSocketSdk.HandleResult.Ok;

            // 释放附加数据
            if (server.SetConnectionExtra(connId, null) == false)
            {
                AddMsg(string.Format(" > [{0},OnClose] -> SetConnectionExtra({0}, null) fail", connId));
            }

            return HandleResult.Ok;
        }
开发者ID:chengfang0911,项目名称:HP-Socket,代码行数:18,代码来源:frmServer.cs

示例10: Init

			/* This is called when reusing a SocketAsyncEventArgs */
			public void Init (Socket sock, SocketAsyncEventArgs args, SocketOperation op)
			{
				result.Init (sock, args, SocketAsyncEventArgs.Dispatcher, op);
				result.Worker = this;
				SocketAsyncOperation async_op;

				// Notes;
				// 	-SocketOperation.AcceptReceive not used in SocketAsyncEventArgs
				//	-SendPackets and ReceiveMessageFrom are not implemented yet
				if (op == Socket.SocketOperation.Connect)
					async_op = SocketAsyncOperation.Connect;
				else if (op == Socket.SocketOperation.Accept)
					async_op = SocketAsyncOperation.Accept;
				else if (op == Socket.SocketOperation.Disconnect)
					async_op = SocketAsyncOperation.Disconnect;
				else if (op == Socket.SocketOperation.Receive || op == Socket.SocketOperation.ReceiveGeneric)
					async_op = SocketAsyncOperation.Receive;
				else if (op == Socket.SocketOperation.ReceiveFrom)
					async_op = SocketAsyncOperation.ReceiveFrom;
				/*
				else if (op == Socket.SocketOperation.ReceiveMessageFrom)
					async_op = SocketAsyncOperation.ReceiveMessageFrom;
				*/
				else if (op == Socket.SocketOperation.Send || op == Socket.SocketOperation.SendGeneric)
					async_op = SocketAsyncOperation.Send;
				/*
				else if (op == Socket.SocketOperation.SendPackets)
					async_op = SocketAsyncOperation.SendPackets;
				*/
				else if (op == Socket.SocketOperation.SendTo)
					async_op = SocketAsyncOperation.SendTo;
				else
					throw new NotImplementedException (String.Format ("Operation {0} is not implemented", op));

				args.SetLastOperation (async_op);
				args.SocketError = SocketError.Success;
				args.BytesTransferred = 0;
			}
开发者ID:nlhepler,项目名称:mono,代码行数:39,代码来源:Socket_2_1.cs

示例11: OnAgentClose

        /// <summary>
        /// 出错了
        /// </summary>
        /// <param name="connId"></param>
        /// <param name="enOperation"></param>
        /// <param name="errorCode"></param>
        /// <returns></returns>
        protected virtual HandleResult OnAgentClose(IntPtr connId, SocketOperation enOperation, int errorCode)
        {
            if(errorCode == 0)
                AddMsg(string.Format(" > [{0},OnAgentClose]", connId));
            else
                AddMsg(string.Format(" > [{0},OnAgentError] -> OP:{1},CODE:{2}", connId, enOperation, errorCode));
            // return HPSocketSdk.HandleResult.Ok;

            // 获取附加数据
            IntPtr extraPtr = IntPtr.Zero;
            if (agent.GetConnectionExtra(connId, ref extraPtr) == false)
            {
                return HandleResult.Error;
            }

            ConnExtraData extra = (ConnExtraData)Marshal.PtrToStructure(extraPtr, typeof(ConnExtraData));

            agent.SetConnectionExtra(connId, null);

            if (extra.FreeType == 0)
            {

                // 由Target断开连接,释放server连接
                extra.FreeType = 1;
                server.SetConnectionExtra(extra.ConnIdForServer, extra);
                extra.Server.Disconnect(extra.ConnIdForServer);
            }

            return HandleResult.Ok;
        }
开发者ID:chengfang0911,项目名称:HP-Socket,代码行数:37,代码来源:TcpPortForwarding.cs

示例12: SocketAsyncResult

		public SocketAsyncResult (Socket socket, AsyncCallback callback, object state, SocketOperation operation)
			: base (callback, state)
		{
			this.socket = socket;
			this.handle = socket != null ? socket.Handle : IntPtr.Zero;
			this.operation = operation;
		}
开发者ID:nickolyamba,项目名称:mono,代码行数:7,代码来源:SocketAsyncResult.cs

示例13: RequestContext

 public RequestContext(SocketOperation operation, ByteBuf data)
 {
     Operation = operation;
     Data = data;
 }
开发者ID:qintao1976,项目名称:Mobius,代码行数:5,代码来源:RioSocketWrapper.cs

示例14: Init

		/* This is called when reusing a SocketAsyncEventArgs */
		public void Init (Socket sock, SocketAsyncEventArgs args, SocketOperation op)
		{
			result.Init (sock, args, SocketAsyncEventArgs.Dispatcher, op, this);

			SocketAsyncOperation async_op;

			// Notes;
			// 	-SocketOperation.AcceptReceive not used in SocketAsyncEventArgs
			//	-SendPackets and ReceiveMessageFrom are not implemented yet
			switch (op) {
			case SocketOperation.Connect:
				async_op = SocketAsyncOperation.Connect;
				break;
			case SocketOperation.Accept:
				async_op = SocketAsyncOperation.Accept;
				break;
			case SocketOperation.Disconnect:
				async_op = SocketAsyncOperation.Disconnect;
				break;
			case SocketOperation.Receive:
			case SocketOperation.ReceiveGeneric:
				async_op = SocketAsyncOperation.Receive;
				break;
			case SocketOperation.ReceiveFrom:
				async_op = SocketAsyncOperation.ReceiveFrom;
				break;
			// case SocketOperation.ReceiveMessageFrom:
			// 	async_op = SocketAsyncOperation.ReceiveMessageFrom;
			// 	break;
			case SocketOperation.Send:
			case SocketOperation.SendGeneric:
				async_op = SocketAsyncOperation.Send;
				break;
			// case SocketOperation.SendPackets:
			// 	async_op = SocketAsyncOperation.SendPackets;
			// 	break;
			case SocketOperation.SendTo:
				async_op = SocketAsyncOperation.SendTo;
				break;
			default:
				throw new NotImplementedException (String.Format ("Operation {0} is not implemented", op));
			}

			args.SetLastOperation (async_op);
			args.SocketError = SocketError.Success;
			args.BytesTransferred = 0;
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:48,代码来源:SocketAsyncWorker.cs

示例15: OnServerError

        /// <summary>
        /// 出错了
        /// </summary>
        /// <param name="connId"></param>
        /// <param name="enOperation"></param>
        /// <param name="errorCode"></param>
        /// <returns></returns>
        protected virtual HandleResult OnServerError(IntPtr connId, SocketOperation enOperation, int errorCode)
        {
            AddMsg(string.Format(" > [{0},OnServerError] -> OP:{1},CODE:{2}", connId, enOperation, errorCode));
            // return HPSocketSdk.HandleResult.Ok;

            // 因为要释放附加数据,所以直接返回OnServerClose()了
            return OnServerClose(connId);
        }
开发者ID:andy521,项目名称:HP-Socket,代码行数:15,代码来源:ProxyServer.cs


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