Re: [lwip-users] smtp app tcp_connect vs lwip_connect
Hi Simon, thanks for your reply. You wrote: There's no need to do that, just use smtp_send_mail_int() , like this: tcpip_callback(smtp_send_mail_int, your_mail_req) where your_mail_req is a pointer to a struct smtp_send_request. I followed this advice, and also removed the malloc for simplicity... and now the test has run stable for 20 minutes and counting (and my server is flooding with emails) :) I probably should have added a big ATTENTION/EXAMPLE not for this somewhere... I was already using smtp_send_mail_int, and looking again I see there are mentions of tcpip_callback everywhere in the comments. I think what threw me was the code example at the top of smtp.c, because it doesn't mention the use of tcpip_callback when smtp_sent_mail_int is mentioned as the NON_SYS==0 approach. Thanks again for writing this application and for your help! Adam. From: lwip-users-bounces+anewman=gai-tronics.co...@nongnu.org [lwip-users-bounces+anewman=gai-tronics.co...@nongnu.org] on behalf of goldsi...@gmx.de [goldsi...@gmx.de] Sent: 07 February 2015 20:07 To: Mailing list for lwIP users Subject: Re: [lwip-users] smtp app tcp_connect vs lwip_connect Newman, Adam wrote: The comments for the smtp app state that the smtp_send_request should be created somewhere safe for interrupt context. Is this at all related to the above unsafe-ness Yes. That is, if I understood you correctly. You should use smtp_send_mail_int (see below) when not calling from tcip_thread. or a seperate issue? I'm not certain when an object that never gets deleted would ever be unsafe for interrupt context but that probably just reflects my level of knowledge on the topic. Yes, it is. I did try creating each smtp_send_request object using a heap_malloc but it still crashes in tcp_input. You did not do that from within tcpip_thread, did you? Is this an issue folks are familiar with i.e. is there a silver bullet? Yes: obey lwIP's threading requirements!!! Or, is it better (and safer) to avoid tcp_connect directly from the application If you mean 'application thread' by 'application', then: yes! and write my own smtp implementation using lwip_connect? There's no need to do that, just use smtp_send_mail_int() , like this: tcpip_callback(smtp_send_mail_int, your_mail_req) where your_mail_req is a pointer to a struct smtp_send_request. I probably should have added a big ATTENTION/EXAMPLE not for this somewhere... Simon Confidentiality Requirement: This communication, including any attachment(s), may contain confidential information and is for the sole use of the intended recipient(s). If you are not the intended recipient, you are hereby notified that you have received this communication in error and any unauthorized review, use, disclosure, dissemination, distribution or copying of it or its contents is strictly prohibited. If you have received this communication in error, please notify the sender immediately by telephone or e-mail and destroy all copies of this communication and any attachments. ___ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users
[lwip-users] unexpected error on recv function via socket
Hi, I meet one unexpected disconnect on recv function. I have one test case and repeat it to test stability: 1. create one socket and connect to server. 2. data exchange with server. 3. close socket. After several runs, it failed on recv function. I get the debug log like below: -- test run : 155 lwip_socket(PF_INET, SOCK_STREAM, 0) = 0 lwip_connect(0, addr=10.0.2.23 port=1) lwip_connect(0) succeeded lwip_send(0, data=2002a938, size=17, flags=0x0) lwip_send(0) err=0 written=17 lwip_recvfrom(0, 2003b9f8, 9, 0x0, ..) lwip_recvfrom: top while sock-lastdata=0 lwip_recvfrom: netconn_recv err=0, netbuf=2000f3cc lwip_recvfrom: buflen=9 len=9 off=0 sock-lastoffset=0 lwip_recvfrom(0): addr=10.0.2.23 port=1 len=9 lwip_recvfrom: deleting netbuf=2000f3cc lwip_recvfrom(0, 2003b9f8, 40, 0x0, ..) lwip_recvfrom: top while sock-lastdata=0 lwip_recvfrom: netconn_recv err=0, netbuf=2000ebac lwip_recvfrom: buflen=40 len=40 off=0 sock-lastoffset=0 lwip_recvfrom(0): addr=10.0.2.23 port=1 len=40 lwip_recvfrom: deleting netbuf=2000ebac lwip_send(0, data=2002a908, size=40, flags=0x0) lwip_send(0) err=0 written=40 lwip_send(0, data=2002a908, size=40, flags=0x0) lwip_send(0) err=0 written=40 lwip_recvfrom(0, 2003b9f8, 40, 0x0, ..) lwip_recvfrom: top while sock-lastdata=0 lwip_recvfrom: netconn_recv err=0, netbuf=2000e79c lwip_recvfrom: buflen=40 len=40 off=0 sock-lastoffset=0 lwip_recvfrom(0): addr=10.0.2.23 port=1 len=40 lwip_recvfrom: deleting netbuf=2000e79c lwip_close(0) test run : 156 lwip_socket(PF_INET, SOCK_STREAM, 0) = 0 lwip_connect(0, addr=10.0.2.23 port=1) lwip_connect(0) succeeded lwip_send(0, data=2002a938, size=17, flags=0x0) lwip_send(0) err=0 written=17 lwip_recvfrom(0, 2003b9f8, 9, 0x0, ..) lwip_recvfrom: top while sock-lastdata=0 lwip_recvfrom: netconn_recv err=-13, netbuf=0 -- error log lwip_recvfrom(0): buf == NULL, error is Not connected.! -- socket still here lwip_close(0) -- The error number is -13 (ERR_CONN). I have no idea about the reason, I check the socket is still exists , not clear at all. Does anyone have some suggestion for me? BTW, I work on TM4C platform with free rtos. thanks Gavin -- View this message in context: http://lwip.100.n7.nabble.com/unexpected-error-on-recv-function-via-socket-tp23842.html Sent from the lwip-users mailing list archive at Nabble.com. ___ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users
Re: [lwip-users] SNTP client does not work
Hi Sylvain, now that it is working it is not really a problem for me. But that's what I have seen: in lwiplib.c / lwIPInit() there is a statement if(lwipIf-ipMode == IPADDR_USE_STATIC) { ip_addr.addr = htonl(lwipIf-ipAddr); net_mask.addr = htonl(lwipIf-netMask); gw_addr.addr = htonl(lwipIf-gwAddr); } which seems to be responsible for exchanging the byteorder. udp_sendto() of the SNTP-code does not seem to do something similar. So that could explain why both behave that different. Karl 2015-02-06 15:08 GMT+01:00 Sylvain Rochet grada...@gradator.net: Hello Karl, On Fri, Feb 06, 2015 at 08:57:06AM +0100, Karl Karpfen wrote: 2015-02-03 15:24 GMT+01:00 Simon Goldschmidt goldsi...@gmx.de: Karl Karpfen wrote: There's nothing strange here: the contents of ip_addr_t needs to be in network byte order and the sntp client calls a function that returns the correct byte order. OK, to clarify that: to get the ip_addr_t that is used to configure my network interface I have to do the following for IP, gateway and netmask: ipaddr_aton(c, globalConfig.ip); globalConfig.ip.addr=htonl(globalConfig.ip.addr); Something is wrong in your setup/port/whatever, what I have is: ipaddr_aton((char*)linebuf, config.ethernet.address4); ipaddr_aton((char*)linebuf, config.ethernet.netmask4); ipaddr_aton((char*)linebuf, config.ethernet.gateway4); netif_add(MACB_if, config.ethernet.address4, config.ethernet.netmask4, config.ethernet.gateway4, NULL, ethernetif_init, tcpip_input); Could you dig deeper into your issue finding the root cause of the problem ? Sylvain ___ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users ___ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users