lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] lwip_connect locks tcpip_thread when trying to connet t


From: Rich Painter
Subject: Re: [lwip-users] lwip_connect locks tcpip_thread when trying to connet to an inactive port
Date: Thu, 12 Jun 2008 11:09:14 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080313 SeaMonkey/1.1.9

Luca,

I dont know if this matters since I'm new to this BUT it has been practice that anything larger than a byte type had to be adjusted for network byte order.

you had :
>   host.sin_port = 21;

Maybe I'm wrong but in BSD sockets for the past 25 years we would write this:
>   host.sin_port = htons(21);



rich


Luca Coppolaro wrote the following on 2008-06-12 5:22 AM:
Hi,
I ported lwIP to a Renesas H8/S CPU running a proprietary cooperative multitasking O.S.
First tests were very positive and httpserver run properly.

Now I'm trying to use sockets but "lwip_connect" never return if it try to connect to an inactive port. I'm porting an FTP client, everything works fine if the FTP server is running, but if the FTP server is stopped "lwip_connect" never returns.

I don't understand what I mistake.

I traced the execution and those are the relevant steps:
- (context: my SYS task) tcpip_apimsg post a message to execute do_connect
- (context: my SYS task) tcpip_apimsg wait for a signal on the semaphore
- (context: TCPIP task) message is fetched and do_connect is called
- (context: TCPIP task) do_connect calls tcp_connect that does NOT send a signal on the semaphore, the signal will be sent from do_connected or err_tcp (see comments in do_connect)
- (context: TCPIP task) destination is unreachable, and many retry are done
- (context: TCPIP task) err_tcp is called when the max retry number is reached - (context: TCPIP task) err_tcp calls execute the macro API_EVENT because conn->recvmbox is not null
- (context: TCPIP task) API_EVENT calls event_callback
- (context: TCPIP task) event_callback calls sys_sem_wait and wait for a signal on the semaphore

Then:
- task SYS is waiting for a signal (it should arrive from err_tcp)
- task TCPIP is waiting for a signal

Who is supposed to send the signal to TCPIP task?????

Many thanks,
Luca

This is what I do in my application:
  // Spawn a task that initialize lwIP and dispatch ethernet packets
  // Wait until lwIP is initialized
  s = lwip_socket(AF_INET, SOCK_STREAM, 0);
  if (s < 0)
    return;
  host.sin_family = AF_INET;
  if (inet_aton("192.168.1.6",&host.sin_addr) == 0)
    // close socket and return
  host.sin_port = 21;
  if (lwip_connect(s, (struct sockaddr *)&host, sizeof(host)) < 0)
    // close socket and return

And those are my application traces (traces with capital TCPIP where added by me)
  TCP/IP initialized.
  Applications started.
  TPCIP: in tcpip_apimsg calling sys_arch_sem_wait (current task is sys)
  tcpip_thread: API message 0x41f4c4
  TCPIP: in tcp_apimsg exited from sys_arch_sem_wait
  lwip_socket(PF_INET, SOCK_STREAM, 0) = 0
  lwip_connect(0, addr=192.168.1.6 port=21)
  TPCIP: in tcpip_apimsg calling sys_arch_sem_wait (current task is sys)
  tcpip_thread: API message 0x41f4c0
  tcpip: etharp_tmr()
  tcpip: etharp_tmr()
  tcpip: etharp_tmr()
  TCPIP: in err_tcp
TCPIP: in err_tcp - calling API_EVENT in the first 'if' statement (never exit)
  TCPIP: in event_callback (conn=0x41b8dc, socket=0)
  TCPIP: in event_callback - active task is tcpip
  TCPIP: in event_callback - calling sys_sem_wait(selectsem) (never exit)
  tcpip: etharp_tmr()
  tcpip: etharp_tmr() .... a lot more follow





_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users


--

Richard A. Painter, P.E.      Phone 719 495 7054
Painter Engineering, Inc.
8470 Swan Rd.                 LatLon: N39.02805   W104.66897
Black Forest, CO 80908        LatLon: N39:1:40.98 W104:40:8.29

Visit our Web sites:          http://painterengineering.com
                              http://usmartdigi.com

Computer, Software, Network and Electronic Forensics
Reverse Engineering + Systems & Software Engineering
LAN WAN Networking + X.25 + INTERNET TCP-IP + Real-time Transaction Processing
System & Software Integration + Testing, Verification & Audits
Web Hosting & Design + Apache + PHP + modSSL + cURL
Math Libraries + Database Design & Applications + Oracle
Benchmarks + Course & Workshop Development & Delivery
Financial and Medical Software Integration + Security
Middleware + EDI + Cryptography + Firewalls
Embedded Hardware & Software Development
Amateur Radio Hardware and Software
UNIX + Linux + Windows

Those who would give up essential liberty to purchase a
little temporary safety, deserve neither liberty nor safety.
 - Ben Franklin, Historical Review of Pennsylvania, 1759

We cannot protect freedom by curtailing it.
    - Michael Hampton, ioerror.us

If you think technology can solve your security problems then
you don't understand the problems and you don't understand
the technology.        - Bruce Schneier

Face it. You have no privacy. Get over it!   - Scott McNealy

For a successful technology, reality must take precedence
over public relations, for Nature cannot be fooled.
                - Richard P. Feynman

The future always arrives too soon and in the wrong order!
   - Alvin Toffler

What is popular is not always right and what is right is not
always popular.     - Howard Cosell

If everyone is thinking alike, someone isn't thinking.  - George Patton

Ned Ludd wasn't completely wrong!

Chance favors the prepared mind!   Illegitima non carborundum

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]