Results 1 to 8 of 8

Thread: Delphi5 TCP/IP Interface Code

  1. #1

    Default

    Here it some Delphi 5 code for sending TCP/IP commands to Girder using the ClientSocket component. Its pretty straight forward, but I hope this tutorial helps.

    The first thing to do is to set up the TCP/IPs Socket connection. To do this start a new application and put a ClientSocket component on the Main Form it is located under the internet tab in the component palette.
    Set the following settings on the CleintSocket Component:

    Active true {this will make the component try to connect to the server on launch of the program}

    Address (set this to the girder machine's IP address, if using this appliation on the same machine running girder set it to that computer's IP address. To find this number you can click on the windows start button, then select Run, and type winipcfg and click ok, choose your network adapter from the list and it will list your comuter's IP number.)

    Client Type ctBlocking

    Port (set this to the port number you specified in the girder TCP/IP plugin)

    {Now the client socket is set up,and we need it to enter the password information. To do this, double click on the ClientSocket component on the Mainform, and enter the follwong between the begin and end statements.}

    ClientSocket1.Socket.SendText('pass *******'); {in place of the ******* put the password you specified in the girder plugin}
    ClientSocket1.Socket.SendText(char(10)); {This sends an Enter command to the girder plugin}


    Your ClientSocket Form should look something like this.

    procedure TForm1.ClientSocket1Connect(Sender: TObject;
    Socket: TCustomWinSocket);
    begin
    ClientSocket1.Socket.SendText('pass girder');
    ClientSocket1.Socket.SendText(char(10));
    end;


    Now when the program starts it will launch the socket connection and automatically enter the password. Be sure to include the IP number of the computer that will be running this program in the Girder TCP/IP Plugin so that it will accept commands from this program.

    This next section will explain how to implement a button that will execute a girder command when pressed.

    Now put a button component on the MainForm from the standard tab in the component palette.
    Double click the button and enter the following between the begin and end statements.

    ClientSocket1.Socket.SendText('execute ***'); {where *** is the command you wish to sent to Girder}
    ClientSocket1.Socket.SendText(char(10));


    Your Button Click procedure should look something like this.

    procedure TForm1.Button5Click(Sender: TObject);
    begin
    ClientSocket1.Socket.SendText('execute mouseup');
    ClientSocket1.Socket.SendText(char(10));
    end;



    Thats it! Compile and run. You can add as many buttons as you wish, the ClientSocket connection remains open while the program is open so there is no need to add additional ClientSocket connections when adding additional buttons. There can also be several instances of this program open on multiple computers and they work simultaneously.

    A similar program can be used to recieve TCP/IP commands from girder's TCP/IP Client Plugin using the ServerSocket component.

  2. #2
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    Darmok,

    Thanks for the great tutorial, i guess
    lots of people will appreciate it!!

    Ron

  3. #3

    Default

    Implementing the TCP/IP server isn't proving as easy as I hoped. I'm now trying to recieve commands in my program from Girder's TCP/IP client plugin, but when I initialize my server using the ServerSocket command and set the girder TCP/IP plugin to the Server's IP address and port number, it seems to get stuck when I try to send the TCP/IP command. Girder stops responding and when I end task it I get an error that says that says asynchronous socket error 10054.

    My Server is only set up to display the text it receives from the client, so I am not having it respond to the password request or anything. This could be the problem, but I was expecting to see some sort of text come through. I haven't looked over the plugin in the SDK to see what its really doing though, so I don't know if it's unable to form a socket connection or if its waiting for a response from my system. Anyway I'm thinking about creating a modified TCP/IP plugin from the SDK source if you didn't mind, and simplifying it a bit by removing the password stuff. Would there be any conflicts with two different TCP/IP client plugins for Girder running simultaneously accessing different port numbers and or IP addresses?

  4. #4
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    The Action plugin is waiting for a welcome message from the server. This message should be in the form of :

    <number>: <text>nr

    for example : (C syntax)

    2: Welcome to the Girder 3.0 TCP/IP interfacenrPlease enter passwordnr

    The number has to be less than 100
    because numbers higher than 99 are
    interpreted as an error message.

    About 2 different plugins using TCP/IP
    that should not be any problem.

    Ron

  5. #5

    Default

    I'm still having troubles getting the programs to communicate properly, so I tried modifying the TCP/IP action plugin from the SDK. I'm having some troubles there too though, because I've never really worked with dll's before. You wouldn't happen to have a very early version of the plugin without the password implemented would you?

  6. #6

    Default

    Ok great, I'll try that. I know that the n is an enter statement or char(10)in Delphi, but what is the r? And do you know what char() would be the equivilent in Delphi?

  7. #7
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    i think char(13)

  8. #8
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    Send me the code and i will have a look at it.

    -Ron

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •