简体   繁体   English

如何在Delphi XE2中建立TCP / IP连接?

[英]How to make TCP/IP connection in Delphi XE2?

I have to develop a simple application in Delphi XE2. 我必须在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. 此应用程序将使用TCP / IP协议连接到具有IP地址(例如xxx.xxx.xxx.xxx)和某些端口号(例如xxxx)的服务器上运行的服务,并将从服务器上运行的服务获得回复。

I have created two textboxes: txtRequestMsg, txtReplyMsg and a button called Connect. 我创建了两个文本框:txtRequestMsg,txtReplyMsg和一个名为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. 我需要打开一个TCP连接并发送一些数据并将一些数据反馈回来,比如ping,但不使用ICMP,只是原始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: 最常用的Delphi互联网库为各种TCP客户端(始发)和TCP服务器(应答)协议提供TCP和UDP组件:

  1. Indy version 10, which is included in the box with your Delphi XE2 installation. Indy版本10,包含在Delphi XE2安装包装盒中。 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. Stackoverflow上有很多人使用这个库,而Indy团队成员经常在这里回答关于Indy的问题,并且它得到了很好的尊重,除非你有真正的理由不使用它,否则你应该从Indy开始。 Ask specific questions about Indy when you've tried something, rather than vague questions like this one, please. 当你尝试某些事情时,询问有关Indy的具体问题,而不是像这样的模糊问题。

  2. ICS by Francois Piette. ICW 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. 我喜欢它,因为代码更小更简单,我发现它比Indy更容易使用,但是使用它的人更少。 There are people on Stackoverflow who use this library, including me, and Francois himself who is active here on SO. Stackoverflow上有人使用这个库,包括我,以及活跃在这里的弗朗索瓦本人。

  3. Synapse. 突触。 I have only used this a bit, but I know lots of people use it. 我只使用过这个,但我知道很多人都使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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