Skip to content

TCP/IP (network) communication

While Zaber devices do not natively support TCP/IP, the serial port connection can be forwarded to TCP/IP using a 3rd party device or a simple program. The library supports this kind of TCP/IP communication, where the library is acting as a TCP client and the converter as a TCP server.

In order to communicate with a TCP server, you need to know its hostname or IP address and on what port the server is listening. In the following example, the server has the IP address "" and listens on the port 12345.

with Connection.open_tcp("", 12345) as connection:
    device_list = connection.detect_devices()
    print("Found {} devices".format(len(device_list)))

    # rest of your program goes here (indented)
using (var connection = Connection.OpenTcp("", 12345)) {
    var deviceList = connection.DetectDevices();
    Console.WriteLine($"Found {deviceList.Length} devices.");

    // rest of your program goes here
const connection = await Connection.openTcp('', 12345);
try {
    const deviceList = await connection.detectDevices();
    console.log(`Found ${deviceList.length} devices.`);

    // rest of your program goes here
} finally {
    // close the port to allow Node.js to exit
    await connection.close();
try (Connection connection = Connection.openTcp("", 12345)) {
    Device[] deviceList = connection.detectDevices();
    System.out.println(String.format("Found %d devices.", deviceList.length));

    // rest of your program goes here
    connection = Connection.openTcp('', 12345);
    deviceList = connection.detectDevices();
    fprintf('Found %d devices.\n', deviceList.length);

    % The rest of your program goes here

catch exception
Connection connection = Connection::openTcp("", 12345);
std::vector<Device> deviceList = connection.detectDevices();
std::cout << "Found " << deviceList.size() << " devices." << std::endl;

// The rest of your program goes here

The example program attempts to connect to a TCP server and detect present devices. If you encounter a problem while connecting, make sure that the server listens on the specified port and is reachable on the network.