lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Re: [lwip] tcp_connect and tcp_listen problems


From: Adam Dunkels
Subject: [lwip-users] Re: [lwip] tcp_connect and tcp_listen problems
Date: Wed, 08 Jan 2003 22:23:09 -0000

Hi Florian!

On Friday 01 February 2002 20:06, you wrote:
> I'm currently writing an ftp server using the raw interface. The ftp server
> should open a connection for sending data (directorys etc) from port 20,
> but when I call tcp_connect, it always gets a new port beginning from 4096.
> It works, but AFAIU rfc0959 it is not correct to do it this way. When I use
> passive mode, I have to listen on a specified port until I get a
> connection. The problem is, the connection seems to be made, but I can't
> send data, because tcp_send thinks the connection is not established.

Yes, tcp_connect() shouldn't pick a new local port if one already is 
assigned. Thanks for pointing this out! Your application uses tcp_bind() to 
bind to port 20 (I assume), and tcp_connect() didn't check if the port was 
already bound. This has been fixed in the latest CVS version.

The second problem *might* be because the return value of tcp_listen() must 
be used instead of the value fed into the function. Like this:

tcp_pcb *pcb;
pcb = tcp_pcb_new();
tcp_bind(pcb, ipaddr, port);
pcb = tcp_listen(pcb);

The reason is that a listening connection uses less memory so it is 
reallocated when it is put in listening mode.

> ps: The raw interface is a real bitch to understand in the beginning, but I
> think it's worth the problems, because the ftp server in the current state
> still works in single threaded mode even with more than one connection.

That certainly is the main advantage of using the raw api: support for 
multiple connections comes for free!

/adam
-- 
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]




reply via email to

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