Dominik99 0 Posted September 16, 2022 Hi! So I made a Websocket server on my Arduino and i try to connect to that with a Delphi 11 program. I use TClientSocket to do that. I wrote a testprogram in Python and everything worked fine, so the problem isn't on hte Arduino's side. The Arduino's IP address is: 192.168.0.24. I also tried the Address like these: 192.168.0.24:6667, ws://192.168.0.24, ws://192.168.0.24:6667. I try to configure the TClientSocket like that: Client := TClientSocket.Create(nil); Client.ClientType := ctNonBlocking; Client.host := 'localhost'; Client.Address := '192.168.0.24'; Client.Port := 6667; Client.Open; This is in a btnClick event. What am I doing wrong? Share this post Link to post
FPiette 385 Posted September 16, 2022 Windows socket error 10061 is a Connection refused error sent to you by the target machine. This means your Arduino server is not running or not listening on the TCP socket you think. Your client may be faulty by using the wrong port or wrong IP or blocked by a firewall rule. Share this post Link to post
Dominik99 0 Posted September 16, 2022 (edited) Yes. Finally figured out, that the Delphi software wants to connect to an Ethernet server not to a Websocket server. Is there any package in Delphi to connect to a Websocket server? Edited September 16, 2022 by Dominik99 Share this post Link to post
Lars Fosdal 1793 Posted September 16, 2022 Why do you specify both a host and an address? What is an "ethernet server" ? Share this post Link to post
Lajos Juhász 295 Posted September 16, 2022 Another question is what is a Websocket server? Last time I checked websocket was a protocol. Share this post Link to post
Dominik99 0 Posted September 16, 2022 In Arduino thats the name of it, Ethernet server. It comes form the Ethernet.h. And yes, its a protocol i mistyped. Share this post Link to post
FPiette 385 Posted September 16, 2022 Ethernet is not TCP/IP. Ethernet is a much lower level that TCP/IP. On a PC, when using TCP/IP, it almost always use Ethernet as lower level transport protocol. Tell us more about what you are EXACTLY using on your Arduino board and which model of Arduino board you are using so that we better understand what you are trying to do. Share this post Link to post
Remy Lebeau 1436 Posted September 16, 2022 8 hours ago, Dominik99 said: I made a Websocket server on my Arduino and i try to connect to that with a Delphi 11 program. I use TClientSocket to do that. I wrote a testprogram in Python and everything worked fine, so the problem isn't on hte Arduino's side. TClientSocket is just a thin wrapper around a TCP socket. WebSocket is a protocol that runs on top of TCP. Thus, TClientSocket will happily connect to a WebSocket server... when used correctly, which you are not... 8 hours ago, Dominik99 said: The Arduino's IP address is: 192.168.0.24 But that is not the IP you are trying to connect to... 8 hours ago, Dominik99 said: I try to configure the TClientSocket like that: ... Client.host := 'localhost'; Client.Address := '192.168.0.24'; ... This is where your mistake is. The Host and Address properties are mutually exclusive, you can only use one of them. The Host has priority over the Address. So, you are trying to connect to 'localhost' (ie 127.0.0.1) only. That is why you are getting an error, since there is no TCP server running on port 6667 on your local machine. You need to either 1) drop the assignment of the Host altogether and just use the Address, or else 2) set the Host to the Arduino's hostname/IP: Client.Host := '192.168.0.24'; 7 hours ago, Dominik99 said: Yes. Finally figured out, that the Delphi software wants to connect to an Ethernet server not to a Websocket server. As far as TClientSocket is concerned, there is no difference. It only knows about TCP, not any protocols on top of TCP (Ethernet is underneath), so if you continue using TClientSocket then you are going to have to implement the WebSocket protocol yourself from scratch. Read RFC 6455 for that. Otherwise, there are plenty of 3rd party WebSocket libraries available that you can use instead. Share this post Link to post