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


C# Socket.BeginSend方法代码示例

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


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

示例1: Send

    public static void Send(Socket client, String data)
    {
        // Convert the string data to byte data using ASCII encoding.
        byte[] byteData = Encoding.ASCII.GetBytes(data);

        // Begin sending the data to the remote device.
        client.BeginSend(byteData, 0, byteData.Length, 0,
            new AsyncCallback(SendCallback), client);
    }
开发者ID:uenowataru,项目名称:WiiDimension,代码行数:9,代码来源:StateObject.cs

示例2: SocketConnection

        internal SocketConnection(URIResolver server, SocketRemote client, Socket socket)
            : base(server, client)
        {
            _socket = socket;

            setActor(new SocketActor(this));

            Buff buff = Buff.getOrCreate();
            int position = buff.position();
            startWrite(buff);
            buff.limit(buff.position());
            buff.position(position);

            if (Debug.ENABLED)
                [email protected](buff.limit());

            _socket.BeginSend(buff.getByteBuffer().array(), buff.position(), buff.remaining(), SocketFlags.None, Connected, buff);

            BeginReceive();
        }
开发者ID:stoneroses,项目名称:objectfabric,代码行数:20,代码来源:SocketConnection.cs

示例3: Send

 // TODO: StateObject is hard-coded to max out at 1024 bytes. Please define somewhere consistent.
 // TODO: Add RTCs for data size. Should not exceed max or be less than zero.
 // TODO: Genericize this to work with other types of data
 public void Send(Socket handler, byte[] data)
 {
     try
     {
         handler.BeginSend(data, 0, data.Length, 0,
             new AsyncCallback(SendCallback), handler);
     }
     catch (SocketException ex)
     {
         Debug.LogWarning(ex.Message);
         players[handler].isActive = false;
         DropConnection(handler);
         events.Add(new SocketEvent(new SocketEventArgs(SocketEventArgs.SocketEventType.DROP, players[handler]), null));
     }
 }
开发者ID:RaskoSmash,项目名称:TankBattle,代码行数:18,代码来源:SocketListener.cs

示例4: Send

    private static void Send(Socket handler, String data)
    {
        try
        {
            // Convert the string data to byte data using ASCII encoding.
            byte[] byteData = Encoding.ASCII.GetBytes(data);

            // Begin sending the data to the remote device.
            handler.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), handler);
        }
        catch (Exception e)
        {
            connected = false;
            Debug.Log(e.ToString());
        }
    }
开发者ID:stefanseibert,项目名称:padawan101,代码行数:16,代码来源:RotationServer.cs

示例5: Send

    private static void Send(Socket handler, String data)
    {
        // Convert the string data to byte data using ASCII encoding.

        Response response = new Response();
        response.Success = true;
        response.Data = data + "Handled by MAIN SEND";
        response.SetImage(new System.Drawing.Bitmap("C:/Work/Projects/Tests/ServerClient/TestServer/TestServer/TestImages/GMan.png"));
        string s = XMLHelper<Response>.SerializeStringToXML(response);

        byte[] byteData = Encoding.ASCII.GetBytes(s);

        // Begin sending the data to the remote device.
        handler.BeginSend(byteData, 0, byteData.Length, 0,
            new AsyncCallback(SendCallback), handler);
    }
开发者ID:Giulio-Ladu,项目名称:ServerClient,代码行数:16,代码来源:Program.cs

示例6: AnotherSend

    private static void AnotherSend(Socket handler, String data)
    {
        // Convert the string data to byte data using ASCII encoding.

        Response response = new Response();
        response.Success = true;
        response.Data = data + "Handled by ANOTHER SEND";

        string s = XMLHelper<Response>.SerializeStringToXML(response);

        byte[] byteData = Encoding.ASCII.GetBytes(s);

        // Begin sending the data to the remote device.
        handler.BeginSend(byteData, 0, byteData.Length, 0,
            new AsyncCallback(SendCallback), handler);
    }
开发者ID:Giulio-Ladu,项目名称:ServerClient,代码行数:16,代码来源:Program.cs

示例7: Send

 private void Send(Socket socket, byte[] data)
 {
     LogsSystem.Instance.Print(string.Format("TCP 发送数据({0}):{1}", data.Length, encoding.GetString(data)));
     socket.BeginSend(data, 0, data.Length, 0, new AsyncCallback(SendCallback), socket);
 }
开发者ID:zhutaorun,项目名称:ACGCard-for-Unity3D,代码行数:5,代码来源:GameClient.cs

示例8: Send

 private void Send(Socket client, string data)
 {
     byte[] byteData = Encoding.UTF8.GetBytes(data);
     client.BeginSend(byteData, 0, byteData.Length, SocketFlags.None, new AsyncCallback(SendCallback), client);
 }
开发者ID:ucjedpfmd,项目名称:U3DGame,代码行数:5,代码来源:Connection2.cs

示例9: SendBinary

    private static void SendBinary(Socket client, byte[] data)
    {
        byte[] byteData = data;

        client.BeginSend(byteData, 0, byteData.Length, 0,
            new AsyncCallback(SendCallback), client);
    }
开发者ID:sevenlabs,项目名称:Labs_AsyncSend,代码行数:7,代码来源:Program.cs

示例10: SendServer

 private static void SendServer(Socket handler, string data)
 {
     byte[] byteData = Encoding.Unicode.GetBytes(data);
     handler.BeginSend(byteData, 0, byteData.Length, 0, SendCallbackServer, handler);
 }
开发者ID:EttienneS,项目名称:Contingency,代码行数:5,代码来源:Program.cs

示例11: Send

    private static void Send(Socket handler, byte[] data, int length)
    {
        var dataClone = data.Clone();

        handler.BeginSend((byte[])dataClone, 0, length, 0,
            new AsyncCallback(SendCallback), handler);
    }
开发者ID:gordonlee,项目名称:testlab,代码行数:7,代码来源:Program.cs

示例12: Send

    private static void Send(Socket handler, String data)
    {
        try
        {
            // Convert the string data to byte data using ASCII encoding.
            byte[] byteData = Encoding.ASCII.GetBytes(data);

            // Begin sending the data to the remote device.
            handler.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), handler);
        }
        catch (Exception e)
        {
            Debug.Log("[ROTATION_SERVER] Network Exception, trying to reconnect. " + e);
            //server.closeConnection();
        }
    }
开发者ID:stefanseibert,项目名称:padawan101,代码行数:16,代码来源:RotationServer.cs

示例13: Send

 //Sends the message and uses SendCallback()
 private void Send(Socket client, String data)
 {
     try
     {
         byte[] byteData = Encoding.ASCII.GetBytes(data); // Convert the string data to byte data using ASCII encoding.
         client.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), client); // Begin sending
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         log.Debug(ex.ToString());
     }
 }
开发者ID:samardzicnenad,项目名称:CooperUnion,代码行数:14,代码来源:AsynchronousClient.cs

示例14: Send

 public void Send(Socket client, byte[] byteData)
 {
     client.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), client);
 }
开发者ID:lwtbn1,项目名称:WWL,代码行数:4,代码来源:NetWorkManager.cs

示例15: Send

	public void Send(Socket socket, byte[] data, int length)
	{
		try {
			socket.BeginSend(data, 0, length, 0,
			                 new AsyncCallback(SendCallback), socket);
		}
		catch (Exception e) {
			Debug.Log("<color=green>S: Send </color>" + e.ToString());
		}
	}
开发者ID:serenitii,项目名称:jeisimple,代码行数:10,代码来源:JangiServer.cs


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