is-open

xod/w5500/is-open

Checks if a TCP connection is open
is-open
@/is-open
Checks if a TCP connection is open
SOCKxod/net/socket
A socket
CHKpulse
Perform the check
is-open
Y
N
SOCK
CHK
Npulse
Pulses if the connection is closed
Ypulse
Pulses if the connection is open

C++ implementation

{{#global}}
#include <Ethernet2.h>
{{/global}}

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    if (!isInputDirty<input_CHK>(ctx))
        return;

    auto client = EthernetClient(getValue<input_SOCK>(ctx));

    if (client.connected()) {
        emitValue<output_Y>(ctx, 1);
    } else {
        emitValue<output_N>(ctx, 1);
    }
}