简体   繁体   中英

How to make TCP/IP connection in Delphi XE2?

I have to develop a simple application in Delphi XE2. This application will connect to a service running on a server with IP Address(say xxx.xxx.xxx.xxx) with some Port No (say xxxx) using TCP/IP protocol and will get reply from the service running on the server.

I have created two textboxes: txtRequestMsg, txtReplyMsg and a button called Connect.

I need to open a TCP connection and send some data and get some data back in response, something like a ping, but not using ICMP, just raw TCP.

The most commonly used Delphi internet libraries that provide TCP and UDP components for various TCP client (originating) and TCP server (answering) protocols are:

  1. Indy version 10, which is included in the box with your Delphi XE2 installation. Almost any of the demos would probably give you enough information to get started, but be prepared to read documentation, too. Nobody is going to teach you in a single stack overflow question how to write network applications. There are MANY people on Stackoverflow who use this library, and an Indy team member is often on here and answers questions about Indy, and it's well respected, and unless you have a real reason not to use it, you should probably start with Indy. Ask specific questions about Indy when you've tried something, rather than vague questions like this one, please.

  2. ICS by Francois Piette. I like it because the code is smaller and simpler and I find it easier to use than Indy, but fewer people use it. There are people on Stackoverflow who use this library, including me, and Francois himself who is active here on SO.

  3. Synapse. I have only used this a bit, but I know lots of people use it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM