add error checking to init function
This commit is contained in:
2023-11-30 22:03:30 +01:00
parent 3d51fde427
commit 2d345b04c3

View File

@@ -356,8 +356,25 @@ static void tcp_cmd_close(struct tcp_pcb* pcb) {
void tcp_cmd_init(void) {
struct tcp_pcb* tcp_pcb;
tcp_pcb = tcp_new();
tcp_bind(tcp_pcb, IP_ADDR_ANY, 23);
if (tcp_pcb == NULL) {
LOG_CRIT(TAG, "Failed to allocate pcb");
return;
}
if (tcp_bind(tcp_pcb, IP_ADDR_ANY, 23) != ERR_OK) {
LOG_CRIT(TAG, "Failed to bind pcb");
free(tcp_pcb);
return;
}
tcp_pcb = tcp_listen(tcp_pcb);
if (tcp_pcb == NULL) {
LOG_CRIT(TAG, "Failed to listen");
free(tcp_pcb);
return;
}
tcp_accept(tcp_pcb, tcp_cmd_accept);
}