is-open

xod-dev/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
To use the node in your project you should have the xod-dev/w5500 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_CHK

#include <Ethernet2.h>

node {
    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);
        }
    }
}