小编Dan*_*Qiu的帖子

如何使用Socket.SendAsync发送大数据

private void ProcessReceive(SocketAsyncEventArgs e)
{
    // Check if the remote host closed the connection.
    if (e.BytesTransferred > 0)
    {
        if (e.SocketError == SocketError.Success)
        {
            Token token = e.UserToken as Token;
            token.SetData(e);

            Socket s = token.Connection;
            if (s.Available == 0)
            {
                Boolean willRaiseEvent = false;
                // GET DATA TO SEND
                byte[] sendBuffer = token.GetRetBuffer();
                // this.bufferSize IS SocketAsyncEventArgs buffer SIZE
                byte[] tempBuffer = new byte[this.bufferSize];
                int offset = 0;
                int size = (int)Math.Ceiling((double)sendBuffer.Length / (double)this.bufferSize);
                for (int i = 0; i …
Run Code Online (Sandbox Code Playgroud)

c# sockets sendasync socketasynceventargs

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

sendasync ×1

socketasynceventargs ×1

sockets ×1