networking · beginner · ~15 min

Is it the HTTPS port?

Recognise the default TLS/HTTPS port.

Challenge

HTTPS is HTTP over TLS, served on port 443 by default. Recognise that port.

Task

Implement int is_https_port(int port) that returns 1 if port is 443, otherwise 0.

Input

One int port.

Output

Returns 1 if port == 443, else 0.

Example

is_https_port(443)   ->   1
is_https_port(80)    ->   0

Input format

One integer port.

Output format

1 if port is 443, else 0.

Constraints

The default HTTPS port is 443.

Starter code

int is_https_port(int port) {
    /* TODO */
    return 0;
}

Common mistakes

Assuming HTTP request header fits in a single recv() buffer; not parsing \r\n line endings properly; failing to send valid HTTP response status.

Edge cases to handle

HTTP requests with headers split across packets; malformed headers lacking colon; empty lines; requests without Content-Length.

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