TcpClientSocketIo

Package: inet.applications.tcpapp

TcpClientSocketIo

simple module

C++ definition

Opens a TCP connection to a given address and port and lets the module connected to its trafficIn and trafficOut gates send and receive data over that connection. When data is received on the trafficIn gate, it is forwarded on the TCP connection via the socketOut gate, and vice versa. This module simplifies the task of data exchange over a TCP connection. The TCP connection is opened when the module first receives data on its trafficIn gate.

By default, reading from the socket is not rate limited. To allow rate limiting, set autoRead=false, and use the readSize and readDelay parameters to set a rate limit. This will allow TCP flow control to come into effect.

<b>See also:</b> ~TcpServerSocketIo

Inheritance diagram

The following diagram shows inheritance relationships for this type. Unresolved types are missing from the diagram.

Used in compound modules

Name Type Description
TcpClientApp compound module

A generic, very modular TCP client application, similar to ~TcpServerApp. The traffic source and traffic sink modules can be built from queueing model elements.

TelnetClientApp compound module

This client application contains a configurable pre-composed telnet traffic source and traffic sink.

Extends

Name Type Description
SimpleModule simple module

Base module for all INET simple modules.

Parameters

Name Type Default value Description
displayStringTextFormat string ""

Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information

localAddress string ""
localPort int -1
connectAddress string
connectPort int
autoRead bool true

Whether to use "autoread" or "explicit-read" mode for TCP connection

readSize int -1B

Used only with autoRead==false

readDelay double -1s

Used only with autoRead==false; delay for issuing a READ command after the previous READ was satisfied; -1 means immediately, 0 means zero delay

Properties

Name Value Description
class TcpClientSocketIo
display i=block/socket

Gates

Name Direction Size Description
trafficIn input
trafficOut output
socketIn input
socketOut output

Source code

//
// Opens a TCP connection to a given address and port and lets the
// module connected to its `trafficIn` and `trafficOut` gates send and receive
// data over that connection. When data is received on the `trafficIn` gate, it is
// forwarded on the TCP connection via the `socketOut` gate, and vice versa. This
// module simplifies the task of data exchange over a TCP connection. The TCP
// connection is opened when the module first receives data on its `trafficIn`
// gate.
//
// By default, reading from the socket is not rate limited. To allow rate
// limiting, set autoRead=false, and use the `readSize` and `readDelay` parameters
// to set a rate limit. This will allow TCP flow control to come into effect.
//
// @see ~TcpServerSocketIo
//
simple TcpClientSocketIo extends SimpleModule
{
    parameters:
        @class(TcpClientSocketIo);
        string localAddress = default("");
        int localPort = default(-1);
        string connectAddress;
        int connectPort;
        bool autoRead = default(true); // Whether to use "autoread" or "explicit-read" mode for TCP connection
        volatile int readSize @unit(B) = default(-1B);    // Used only with autoRead==false
        volatile double readDelay @unit(s) = default(-1s);    // Used only with autoRead==false; delay for issuing a READ command after the previous READ was satisfied; -1 means immediately, 0 means zero delay
        @display("i=block/socket");
    gates:
        input trafficIn;
        output trafficOut;
        input socketIn;
        output socketOut;
}
File: src/inet/applications/tcpapp/TcpClientSocketIo.ned