sebus_1985
Newbie level 3
Hello. Sorry for my english.I don't have any experience in programming TCP, and I have a problem with LwIP. I want to make a tcp client on the stm32f107 (butterfly board from kamami.pl) which will connect to server on my computer. I found a python server code which is the best for me. Is there someone who knows how to start a client. I know how the tcp protoclol works but i don't know how this library works and what function should I use. There is some code which i made but it doesn't work. I used a stm32 demo library.
Code:
struct ip_addr server_ip;
struct ip_addr client_ip;
...
void HelloWorld_init(void)
{
IP4_ADDR(&server_ip,192,168,0,6);
IP4_ADDR(&client_ip,192,168,0,33);
struct tcp_pcb *pcb;
/* Create a new TCP control block */
pcb = tcp_new();
/* Assign to the new pcb a local IP address and a port number */
/* Using IP_ADDR_ANY allow the pcb to be used by any local interface */
tcp_bind(pcb, &client_ip, 80);
//tcp_connect(pcb, &server_ip, 80, tcp_client_connected_l);
//int i;
//for(i=0;i<2000;i++);
//tcp_write(pcb, HELLO, strlen(HELLO), 1);
/* Set the connection to the LISTEN state */
//pcb = tcp_listen(pcb);
/* Specify the function to be called when a connection is established */
tcp_accept(pcb, HelloWorld_accept);
tcp_connect(pcb, &server_ip, 80, tcp_client_connected_l);
tcp_write(pcb, HELLO, strlen(HELLO), 1);
}