cancel
Showing results for 
Search instead for 
Did you mean: 

Can I write to 2 different ports using two pcbs? (LWIP, raw API) It seems to only write to 1 twice?

JMcIn.2
Associate

I'm trying to provide a server connection to 2 clients on ports 1024 and 1025 using LWIP raw API. I have created two separate pcbs and can listen on both ports successfully, but writing to either pcb results in data being sent to the first pcb only;

//initialize connections to Ports 1024 and 1025

void Eth_Init(){

pcb_out1 = tcp_new();

tcp_bind(pcb_out1, IP_ADDR_ANY , 1024);

pcb_in1 = tcp_listen(pcb_out1);

tcp_accept(pcb_in1,connection_accept1);

pcb_out2 = tcp_new();

tcp_bind(pcb_out2, IP_ADDR_ANY , 1025);

pcb_in2 = tcp_listen(pcb_out2);

tcp_accept(pcb_in2,connection_accept2);

}

//attempt to write to both ports but 1024 receives the str twice?

void Eth_Write_String(char *str){

tcp_write(pcb_out1, str, strlen(str), TCP_WRITE_FLAG_COPY);

tcp_output(pcb_out1);

tcp_write(pcb_out2, str, strlen(str), TCP_WRITE_FLAG_COPY);

tcp_output(pcb_out2);

}

Any help is appreciated...

1 REPLY 1
JMcIn.2
Associate

P.S. Using NUCLEO F746ZG development board and STM32CubeIDE