Softimage TCP Server



This plugin provides 2 examples of a TCP/IP server implementation for Softimage. The first example is a C# server which manages client connections asynchronously and can execute requests received from client connections.

Note: The C# example is not available on Linux.


The XSIClientSample command-line application can be used for sending requests to the Softimage server.

Example:
XSIClientSample.exe "log|my message" -> logs "my message" in the history window.
XSIClientSample.exe "script|c:\\temp\\test.vbs" -> executes the test.vbs script in Softimage (any Softimage script language can be used)
Note: The above examples work if the XSIServer is connected on the localhost (127.0.0.1) on port 10000.

You can also specify the full address and connection port to XSIClientSample.exe:
XSIClientSample.exe "log|Send to 172.24.40.132 on port 50010" "172.24.40.132" 50010
XSIClientSample.exe "script|c:\\temp\\test.vbs" "172.24.40.126" 50010

The second example is a python TCP server which also manage client connections asynchronously. The tcpclient.py example can be used for sending requests to the TCP server.

Example:
##tcpclient.py
from socket import *
 
HOST = 'localhost'
PORT = 5007    #our port from before
ADDR = (HOST,PORT)
BUFSIZE = 4096
 
cli = socket( AF_INET,SOCK_STREAM)
cli.connect((ADDR))

cli.send('xyz_request:Torus')
 
data = cli.recv(1024)
        
print 'request result %s' % (data) 

cli.close()

Example Files

Location
Files
XSIServer.cs
XSITCP.cs
XSIServiceProvider.cs
XSIHelpers.cs
main.cs
si_tcp_server.py
tcpclient.py

Running the examples

To run the C# TCP Server Example

  • From the XSIServer_Menu menu located in the main menu bar, click Properties. The Softimage Server property page opens.
  • Click the Start radio-button.
  • Open a Softimage command prompt, and type the following:

    XSIClientSample.exe "log|Message sent from XSIClientSample"
    
  • The Softimage Scripting Editor window displays the message (if you have activated the Log Verbose Messages preference).

To run the python TCP Server Example

  • From the SI TCP Server menu located in the main menu bar, click Start to run the server.
  • Open a Softimage command prompt, and type the following:

    python.exe tcpclient.py
    
  • A new torus should be created in Softimage and the following is logged on the command-linerequest result done.

Building the Softimage C# TCP Server Example

Softimage SDK includes a compiled version of XSIServer and XSIClientSample. If you want to modify the code, you can rebuild the example by following these instructions.

To build the example on Windows

  1. Open an Softimage command prompt, and type devenv to start Visual Studio .NET.

    Starting Visual Studio .NET from an Softimage command prompt ensures that environment variables such as XSI_HOME are set (otherwise you'll get build and link errors).

    Tip To load the XSIServer project from the command line, type:

    devenv cssrc\XSIServer.csproj
    
  2. In Visual Studio .NET, open the project file XSIServer.csproj.
  3. Select a configuration (Release or Debug) and build the DLL.
  4. To build XSIClientSample: open the project file XSIClientSample.csproj.
  5. Select a configuration (Release or Debug) and build the DLL.

Keywords

This example uses the following keywords:

C#, TCP/IP, RegisterCommand, RegisterProperty, RegisterMenu, RegisterTimerEvent.