tcp_cmd
add error checking to init function
This commit is contained in:
@@ -356,8 +356,25 @@ static void tcp_cmd_close(struct tcp_pcb* pcb) {
|
|||||||
void tcp_cmd_init(void) {
|
void tcp_cmd_init(void) {
|
||||||
struct tcp_pcb* tcp_pcb;
|
struct tcp_pcb* tcp_pcb;
|
||||||
tcp_pcb = tcp_new();
|
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);
|
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);
|
tcp_accept(tcp_pcb, tcp_cmd_accept);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user