The method connServerDemo() in the type TCPClient is not applicable for the arguments (String, int)
时间: 2024-03-31 11:34:46 浏览: 18
这错误提示是说 `TCPClient` 类中的 `connServerDemo()` 方法不接受 `String` 和 `int` 两个参数。你需要检查你的代码,看看在哪里调用了 `connServerDemo()` 方法,并且确认你传递的参数类型和方法定义中的参数类型一致。如果不一致,你需要修改方法定义或修改参数类型以匹配方法定义。
相关问题
Cannot make a static reference to the non-static method connServerDemo(String, int) from the type TCPClient
这个错误提示是说你不能通过类名直接调用一个非静态方法,因为非静态方法是需要实例化对象后才能使用的。你需要先创建一个 `TCPClient` 对象,然后通过这个对象来调用 `connServerDemo(String, int)` 方法。示例代码如下:
```
TCPClient client = new TCPClient();
client.connServerDemo("localhost", 8080);
```
这样就可以避免这个错误了。
delphi indy10 tcpclient收发string
可以使用 Indy10 的 TIdTCPClient 组件来进行 TCP 连接和数据收发。以下是一个简单的示例:
```delphi
var
TCPClient: TIdTCPClient;
Response: string;
begin
TCPClient := TIdTCPClient.Create(nil);
try
TCPClient.Host := '127.0.0.1'; // 设置服务器地址
TCPClient.Port := 1234; // 设置服务器端口号
TCPClient.Connect; // 连接服务器
TCPClient.IOHandler.WriteLn('Hello, server!'); // 发送数据
Response := TCPClient.IOHandler.ReadLn; // 接收数据
ShowMessage(Response); // 显示接收到的数据
TCPClient.Disconnect; // 断开连接
finally
TCPClient.Free;
end;
end;
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)