socketstcplazarusfreepascal

How can I open a TCP connection to a specific TCP port, send a string and read the response in Lazarus?


I'd like to do this without any external libraries if at all possible...

I want to open a TCP connection to a specific port on a specific IP address and then communicate by sending ANSI strings and receive an ANSI string response.

Sadly, I have no idea where to start with this, and searching the internet turns up what seem like pretty complex examples.

Can anyone give me any starting point?


Solution

  • You can use an excellent, free and multiplatform library called Synapse. It has built-in support for many protocols (FTP, HTTP, POP3, LDAP and so on), and it also allows you to implement your own protocols. You can write your own clients and servers with just few lines of code—amazing!

    It has excellent debug capabilities, it's very fast and code efficient. Just look at the demos in the HOWTO area.

    If you like detailed information regarding Synapse with Free Pascal and Lazarus look at Synapse (wiki).