lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] connection unsuccessful


From: Kieran Mansley
Subject: Re: [lwip-users] connection unsuccessful
Date: Tue, 31 Jul 2007 08:55:26 +0100

On Tue, 2007-07-31 at 00:15 +0200, Luigi wrote:
> Hi,
> I'm trying to create a comunication between a client and an echo
> server;
> when the client start the connection the server respond well (I seem),
> but when I try to send a message from the client, the client turn out
> unconnected,
> and I don't understand where is the error.

I'm pretty sure it's this: you never initialise the value of "pcb" in
your main function, but then you use that variable to call cli_send().

You correctly allocate a pcb in cli_init() for calling to tcp_connect(),
but the pcb you will use for data transfer could be a different one.
The pcb you should use for calling cli_send() is the "newpcb" returned
to your cli_connected() callback.

You therefore need to wait in your main function until cli_connected()
has been called, get the value of newpcb from the cli_connected()
callback and then use that value to call cli_send().

Other little things:
 - You don't need to add PBUF_TRANSPORT_HLEN onto the size when you
allocate a pbuf.  The first argument (PBUF_TRANSPORT) tells lwIP that
this is necessary and it does it for you.
 - You need to call tcp_output() after tcp_write() if you want the data
to go out onto the network as soon as possible.

Hope that helps

Kieran





reply via email to

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