networking · beginner · ~15 min

Is it a stream socket?

Recognise the stream socket type constant.

Challenge

Implement int is_stream_socket(int type) returning 1 if type is SOCK_STREAM (TCP), else 0.

Starter code

#include <sys/socket.h>

int is_stream_socket(int type) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.