admin

[网络类] delphi 之 diocp tcpserver 接收回复数据

procedure TForm1.icptcpsrvr1DataReceived(

  pvClientContext: TIocpClientContext; buf: Pointer; len: Cardinal;

  errCode: Integer);

var

  s:AnsiString;

begin

  if errCode = 0 then

  begin

    SetLength(s, len);

    Move(buf^, s[1], len);

    mmo1.Lines.Add('接收到客户端[' + pvClientContext.RemoteAddr + ']数据:' + s);

    pvClientContext.PostWSASendRequest(PAnsiChar('Sucess'), Length('Sucess'));

    //pvClientContext.PostWSASendRequest(buf, len);

  end else

  begin

    pvClientContext.DoDisconnect;

  end;

end;


#1楼
发帖时间:8月前   |   查看数:0   |   回复数:0
游客组