Search code examples
network-programmingc++builderindyindy10c++builder-6

TCP issue with C++Builder 6 and Indy 10


I am writing an application using C++Builder 6 and Indy 10. The application uses the UDP protocol to communicate with modules (AVR). Everything works fine. Unfortunately, now I need to control an external device (Marantz receiver) that uses TCP instead.

The device starts responding to the frames sent over TCP all nice .... but then then application freezes and crashes. Whatever I try to do crashes with an Access Violation error.

I have a few questions:

  1. Can the TCP/IP stack operate in parallel with UDP packets that are sent to other modules?

  2. Does the TIdTCPClient::Disconnect() method affect UDP?

The application is working properly with UDP without controlling Marantz. But exchanging the supposedly correct TCP messages is freaking out the application. I tried different way to disconnect the stack (clearing the IO buffer before disconnecting, etc).


Solution

  • TCP runs just fine in parallel with UDP. Do note, however, that Indy uses all sockets in blocking mode, so if you want to use TCP and UDP in the same application at the same time, you will have to make use of worker threads to keep them from blocking each other.

    The TCP protocol itself does not affect the UDP protocol, and vice versa, in any way.

    Access Violation errors mean your code is accessing invalid memory at runtime. Which means you are likely using TIdTCPClient incorrectly. But since you did not show any of your actual code, or provide any documentation or examples of the Marantz protocol, nobody can tell you what you are doing wrong.