我的TcpServer同时有多个客户连接上来如果所有客户的网络速度都比较快,那不会有任何问题。
一旦有一个网络速度很慢的用户上来,会导致其他所有用户速度慢下来,他一退出,其他用户都正常了。
  try
    videoheard.Flag := packflag;
    if (Athread.Connection <> nil) and (Athread.Connection.Connected) then
    begin
      Athread.Connection.OpenWriteBuffer();
      Athread.Connection.WriteBuffer(videoheard,sizeof(videoheard));
      Athread.Connection.WriteBuffer(buf,bufsize);
      Athread.Connection.CloseWriteBuffer();
    end;
  finally
  end;我觉得是不是这个WriteBuffer,没有在线程中发送 ?  还在主线程,所以他返回慢,就其他都很慢了?
有什么办法解决吗?

解决方案 »

  1.   

    WriteBuffer 能不能瞬间执行完毕,不等待?这样就不会卡住了!
      

  2.   

    我的测试
          Athread.Connection.OpenWriteBuffer();
          vTickCount   :=   GetTickCount;
          Athread.Connection.WriteBuffer(videoheard,sizeof(videoheard));
          Athread.Connection.WriteBuffer(buf,bufsize);
          addtipinfo(IntToStr(GetTickCount - vTickCount));
          Athread.Connection.CloseWriteBuffer();发现writebuffer非常快,慢在closewritebuffer上面于是我修改如下      vTickCount   :=   GetTickCount;
          stream.WriteBuffer(videoheard,sizeof(videoheard));
          stream.WriteBuffer(buf,bufsize);
          stream.Position := 0;
          Athread.Connection.WriteBuffer(stream.memory^,stream.size);
          addtipinfo(IntToStr(GetTickCount - vTickCount));
    结果writebuffer慢了。怎么办?