Jump to content

Search the Community

Showing results for tags 'indy tcp client'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Delphi Questions and Answers
    • Algorithms, Data Structures and Class Design
    • VCL
    • FMX
    • RTL and Delphi Object Pascal
    • Databases
    • Network, Cloud and Web
    • Windows API
    • Cross-platform
    • Delphi IDE and APIs
    • General Help
    • Delphi Third-Party
  • C++Builder Questions and Answers
    • General Help
  • General Discussions
    • Embarcadero Lounge
    • Tips / Blogs / Tutorials / Videos
    • Job Opportunities / Coder for Hire
    • I made this
  • Software Development
    • Project Planning and -Management
    • Software Testing and Quality Assurance
  • Community
    • Community Management

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Delphi-Version

Found 1 result

  1. @rturas

    Indy TCP client

    Hello, I am trying to create the app that sends a messages to the server and gets back an answer from it in a thread on the regular time intervals. Request contains 6 bytes, answer should be 65 bytes. My code looks like that: //TThread Constructor inherited Create(True); TCPClient := TIdTCPClient.Create; TCPClient.Host := AHost; TCPClient.Port := APort; TCPClient.ConnectTimeout := 5000; TCPClient.ReuseSocket := rsTrue; //TThread Execute procedure SetLength(wBuffer, 6); //Here i do write some bytes SetLength(rBuffer, 65); while not Terminated do begin try TCPClient.Connect; except on E: Exception do begin TThread.Queue(nil, procedure begin Form2.mmo1.Lines.Add('Exception: ' + e.Message); end); for i := 1 to 5 do begin if not Terminated then Sleep(1000); end; Continue; end; end; Reading := False; i := 1; while not Terminated do begin if not Reading then begin Reading := True; TCPClient.IOHandler.Write(wBuffer, 6, 0); end; try if Reading then begin if TCPClient.IOHandler.CheckForDataOnSource(100) then begin TCPClient.IOHandler.ReadBytes(rBuffer, 65, False); TThread.Queue(nil, procedure begin Form2.mmo1.Lines.Add('Buffer size: ' + IntToStr(TCPClient.IOHandler.InputBuffer.Size)); end); if not TCPClient.IOHandler.InputBufferIsEmpty then begin //I do some stuff here i := i +1; Reading := False; Sleep(1000); end; end; end; except on E: Exception do begin TThread.Queue(nil, procedure begin Form2.mmo1.Lines.Add('Reading exception: ' + e.Message); end); Sleep(1000); Continue; end; end; end; end; I do get only one line in the memo: Buffer size: 0 What am i doing wrong? How can i fix it? Thank you in advance.
×