• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - CDP Core
  • TCPTransport
  • 5.0.0

TCPTransport Class

(CDP::IO::TCPTransport)

The TCPTransport is a class used to simplify the handling of configurable TCP communication in an IOServer. More...

Header: #include <TCPTransport>
Inherits: NetworkTransport and TCPConnection
  • List of all members, including inherited members

Public Functions

TCPTransport(const std::function<unsigned int( Transport *, char *, unsigned int ) > readCallbackHandler)

Reimplemented Public Functions

virtual void Close() override
virtual std::string GetNodeTypeName() const override
virtual bool IsError() override
virtual bool IsOpen() const override
virtual bool Open(Transport::OpenMode mode) override
virtual unsigned int Read(char *data, unsigned int length, double timeout = 0.0) override
virtual unsigned int Write(const char *data, unsigned int length, double timeout = 0.0) override
  • 10 public functions inherited from CDP::IO::NetworkTransport
  • 33 public functions inherited from TCPConnection
  • 12 public functions inherited from CDP::IO::Transport
  • 27 public functions inherited from CDP::StudioAPI::CDPNode
  • 22 public functions inherited from CDP::StudioAPI::ICDPNode

Additional Inherited Members

  • 1 static public member inherited from TCPConnection
  • 1 static public member inherited from CDP::IO::Transport
  • 1 protected function inherited from CDP::StudioAPI::CDPNode

Detailed Description

The TCPTransport is a class used to simplify the handling of configurable TCP communication in an IOServer.

See also Transport, UDPTransport, and NetworkTransport.

Member Function Documentation

TCPTransport::TCPTransport(const std::function<unsigned int( Transport *, char *, unsigned int ) > readCallbackHandler)

Constructs the TCP Transport, passing in the readCallbackHandler

[override virtual] void TCPTransport::Close()

Reimplemented from Transport::Close().

Closes the socket(s)

[override virtual] std::string TCPTransport::GetNodeTypeName() const

Reimplemented from ICDPNode::GetNodeTypeName().

Returns "TCPTransport"

[override virtual] bool TCPTransport::IsError()

Reimplemented from Transport::IsError().

Returns true if there is a socket error, false if not.

[override virtual] bool TCPTransport::IsOpen() const

Reimplemented from Transport::IsOpen().

Returns true if tcpconnection is connected, false if not.

[override virtual] bool TCPTransport::Open(Transport::OpenMode mode)

Reimplemented from Transport::Open().

Tries to connect the TCP connection to the configured IP/port

[override virtual] unsigned int TCPTransport::Read(char *data, unsigned int length, double timeout = 0.0)

Reimplemented from Transport::Read().

Reads length bytes of data from the tcp socket within timeout [seconds]. If timeout<=0.0, the timeout from the configuration is used. Returns number of bytes read.

It is assumed that data is a buffer that the caller has allocated, and that it is at least length bytes long. Read will block for how long it takes to read the data, or for timeout seconds, whichever comes first.

As Read() is a blocking call, do not call it from a Process() function. See CDPComponent and OSAPIThread for more information about component threads.

[override virtual] unsigned int TCPTransport::Write(const char *data, unsigned int length, double timeout = 0.0)

Reimplemented from Transport::Write().

Sends the data to the configured ip/port unless there is a timeout Returns amount of bytes sent.

It is assumed that data is a buffer that the caller has allocated, and that it is at least length bytes long. Write will block for up to timeout seconds for the output to be ready before attempting to write the data.

As Write() is a blocking call, do not call it from a Process() function. See CDPComponent and OSAPIThread for more information about component threads.

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top