--- Quote Start ---
Guys,I am in troubles.
First of all,I cannot get this example working.
Basically, I need to build application, similar to FTP. Application, which has two(2) open connections with two ports.Over one of ports, received commands and sent responses.
Over second port,I send data.But this is in general.
At this stage I want to build application (based on BillA's example), which shall be able to receive packets from other side(PC,for example).
When i use BillA's example,and there is connection to external net,i receive the packets,exactly like BillA sad, but it happens not on Transport layer(not by tcp_... functions).I think,it happens on IP leyer(by netif... functions).
--- Quote End ---
Why do you say this?
If you use the code in httpd.c, you see how to make a connection, handle incoming data (replace http_recv with your function), send data (send data first and then send subsequent data (if any) using the http_sent callback).
HTTP runs on top of TCP so this is using the TCP transport. If you want a reliable connection this is how you should do it.
--- Quote Start ---
If i want to receive packets, do i need to define callback functions and why?
--- Quote End ---
Yes. Because the stack runs and gets data at any time so you have to be expected to be told when data is there - at any time. You response to that data (your commands) by sending data out (on the same connection or another if you choose).
--- Quote Start ---
If YES, how to do it? Somebody can show me on example.I do not need the application,i need a little push,some help.
--- Quote End ---
Use the code in httpd.c - replace http_recv with your incoming data handler, and send data as is done there - use http_send and use the http_sent callback if one call to send data isn't enough (you cannot control this because of the tcp_sndbuf check so implement sending just as is done in httpd.c).
--- Quote Start ---
P.S. When i tried to fined the problem, i fount,that in httpd.c file in httpd_init there is some error(maybe it is not an error and it is suppose to be like this,but i think there is an error).
In line:
pcb = tcp_listen(pcb); tcp_listen function returns NULL and think it is must be different.
--- Quote End ---
Maybe you need to change LWIPOPTS.h to allow for more TCP connections or PCBs? It is an error to return NULL and you need to debug why but my guess is not enough resources for your call.
Bill A