Hi, TCP programming is not my strongest point, but I would like to give it a try.
Programming language : Delphi XE3 and using Indy TCP Client.
I’ve seen and read (I think) all topics about this on this forum, but what I would like to see is a clear and complete sequence to connect and send a command to the VM201 to set a switch.
I’ve been figuring out a lot, but it comes to nowhere, because I can’t see what is going on.
Can you please give me a code example or some snippets with wich I can make a command to work properly instead of trying for several more days and get so frustrated that I throw this whole in the trashcan?
I love Delphi as well. Have been used it from D1 until D7 and now in XE2, XE3 and XE4.
I would like to use the Indy TCP client because the TClientSocket is not xplatform (as far as I know) and I want to build an application wich can be compiled to Windows 32bit, 64 bit and MAC OSx (and probably later this year to Android) as well.
I will give it a try!
One minor thing: when I compile the project, without any changes and set authentication (username and password of admin f.i.) in the webinterface, the application asks for that authentication. It however always fails. When I turn authentication of in the webinterface, it workd fine. It also works fine when I use the webinterface and the downloaded VM201 executable.
Is this a known problem?
It is originally a Delphi 7 application, so something may have been broken during conversion. You can use breakpoints to check if the username and password are sent correctly.
I’ve seen in VM201 unit the authenticate function, where a Move has been used to set the data for userid and password. Sometimes the Move seems not to work and I have changed this to:
// Move(Username[1], (@Packet.RawData[3])^, Length(Username));
ls := Length(Username);
for i := 1 to ls do
packet.RawData[2+i] := Ord(Username[i]);
Also for the password:
ls := Length(Password);
for i := 1 to ls do
packet.RawData[2+i] := Ord(Password[i]);