RAD Studio
ContentsIndex
PreviousUpNext
Specifying a Connection Using Sockets

You can establish a connection to the application server using sockets from any machine that has a TCP/IP address. This method has the advantage of being applicable to more machines, but does not provide for using any security protocols. When using sockets, include a TSocketConnection component for connecting to the application server. 

TSocketConnection identifies the server machine using the IP Address or host name of the server system, and the port number of the socket dispatcher program (Scktsrvr.exe) that is running on the server machine. For more information about IP addresses and port values, see Describing sockets

Three properties of TSocketConnection specify this information:

  • Address specifies the IP Address of the server.
  • Host specifies the host name of the server.
  • Port specifies the port number of the socket dispatcher program on the application server.
Address and Host are mutually exclusive. Setting one unsets the value of the other. For information on which one to use, see Describing the host

If you have multiple servers that your client application can choose from, you can use the ObjectBroker property instead of specifying a value for Address or Host. For more information, see Brokering connections

By default, the value of Port is 211, which is the default port number of the socket dispatcher program that forwards incoming messages to your application server. If the socket dispatcher has been configured to use a different port, set the Port property to match that value.

Note: You can configure the port of the socket dispatcher while it is running by right-clicking the CodeGear Socket Server tray icon and choosing Properties.
Although socket connections do not provide for using security protocols, you can customize the socket connection to add your own encryption.

To add your own encryption

  1. Create a COM object that supports the IDataIntercept interface. This is an interface for encrypting and decrypting data.
  2. Use TPacketInterceptFactory as the class factory for this object. If you are using a wizard to create the COM object in step 1, replace the line in the initialization section that says TComponentFactory.Create(...) with TPacketInterceptFactory.Create(...).
  3. Register your new COM server on the client machine.
  4. Set the InterceptName or InterceptGUID property of the socket connection component to specify this COM object. If you used TPacketInterceptFactory in step 2, your COM server appears in the drop-down list of the Object Inspector for the InterceptName property.
  5. Finally, right click the CodeGear Socket Server tray icon, choose Properties, and on the properties tab set the Intercept Name or Intercept GUID to the ProgId or GUID for the interceptor.
This mechanism can also be used for data compression and decompression.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!