基于TCP/IP的Socket通讯中,我的客户端是非阻塞方式,服务器发送数据非常快(包头信息和一条记录组成一个包发送,且有非字符类型数据,不能用ReceiveText而应用ReceiveBuf来接收),我该怎么办呢?

解决方案 »

  1.   

    你应该,在接收到某信息再发,先用ReceiveText='',然后再sendbuf
      

  2.   

    楼上的朋友是什么意思呢?我的包里不都是char类型,也有longint等类型,请具体指点,谢谢!!!
      

  3.   

    应该不会跟不上的。发送端没发送一条,sleep(10), 停顿0.01毫秒或更长些,就可。接收端收到一条,就将收到的消息,放入一个缓冲区(自己定义,可以是数组、本地数据库、文件等等),然后马上进入准备接受下一个消息的状态。千万不要,接受一条就一直等到这条消息引发的所有处理完成,再准备接受下一个消息,如果,你是这样,是会慢的。
      

  4.   

    You may alloc a ring buffer has a read pointer and a write pointer in client application.In the client there must be at least two threads-one for read data from socket to the ring buffer,another process the data in the buffer.It's important not to make the buffer overflow:)
      

  5.   

    repeat
      nretr:=Socket.ReceiveBuf( buf,sizeof(buf) );   //do somethinguntil nretr<=0;