Re: [lwip-users] Raw lwIP server write issue

2015-11-05 Thread Valery Ushakov
Amit Ashara  wrote:

> When a connection is established between the server and the client,
> I can use the tcp_write on the client side to send data in my
> application code.  However the same on the server side is not
> possible.  The pcb that has been used for the server only contains
> the server's address and server's port but not the client's address
> and client's port.  In the receive call back on the server side, I
> can send the data to the client but not outside of the call back.

You are using wrong pcb.  On the server you start with a listening
pcb.  When your accept callback is called, it's passed a *new* pcb,
that represents the established connection.  You should use that pcb
for tcp_write.  Writing from receive callback works because in the
receive callback the pcb argument is that connection pcb, not the
original listening pcb.

-uwe


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


Re: [lwip-users] Raw lwIP server write issue

2015-11-05 Thread Amit Ashara
Hello Uwe,

I have the call back for accept set as follows.

In the main application, I call echo_accept.

server_tpcb = tcp_new();
ui32Err = tcp_bind(server_tpcb, (ip_addr_t
*)_ui32IPAddress, NODE_TCP_SERVER_PORT);
UARTprintf("\n%d",ui32Err);
server_tpcb = tcp_listen(server_tpcb);
tcp_accept(server_tpcb, echo_accept);

which is as follows.

static err_t echo_accept(void *arg, struct tcp_pcb *pcb, err_t err)

{
  LWIP_UNUSED_ARG(arg);
  LWIP_UNUSED_ARG(err);

  tcp_setprio(pcb, TCP_PRIO_MIN);
  tcp_arg(pcb, NULL);
  tcp_recv(pcb, echo_recv);
  tcp_err(pcb, echo_err);
  tcp_poll(pcb, NULL, 0);
  return ERR_OK;
}

Do you mean that instead of using pcb I should have another tcp_pcb e,g,
newpcb that is assigned from the pcb in the call back.

struct tcp_pcb *newpcb;

static err_t echo_accept(void *arg, struct tcp_pcb *pcb, err_t err)

{
  LWIP_UNUSED_ARG(arg);
  LWIP_UNUSED_ARG(err);

  newpcb = pcb;

  tcp_setprio(pcb, TCP_PRIO_MIN);
  tcp_arg(pcb, NULL);
  tcp_recv(pcb, echo_recv);
  tcp_err(pcb, echo_err);
  tcp_poll(pcb, NULL, 0);
  return ERR_OK;
}

Regards
Amit

On Thu, Nov 5, 2015 at 11:28 AM, Valery Ushakov  wrote:

> Amit Ashara  wrote:
>
> > When a connection is established between the server and the client,
> > I can use the tcp_write on the client side to send data in my
> > application code.  However the same on the server side is not
> > possible.  The pcb that has been used for the server only contains
> > the server's address and server's port but not the client's address
> > and client's port.  In the receive call back on the server side, I
> > can send the data to the client but not outside of the call back.
>
> You are using wrong pcb.  On the server you start with a listening
> pcb.  When your accept callback is called, it's passed a *new* pcb,
> that represents the established connection.  You should use that pcb
> for tcp_write.  Writing from receive callback works because in the
> receive callback the pcb argument is that connection pcb, not the
> original listening pcb.
>
> -uwe
>
>
> ___
> 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

[lwip-users] Raw lwIP server write issue

2015-11-05 Thread Amit Ashara
Hello All,

I am using Raw lwIP 1.4.1 on a microcontroller. Since the requirement is to
have acknowledged transfer between two devices, I created a server and
client model. However I ran into an issue.

When a connection is established between the server and the client, I can
use the tcp_write on the client side to send data in my application code.
However the same on the server side is not possible. The pcb that has been
used for the server only contains the server's address and server's port
but not the client's address and client's port. In the receive call back on
the server side, I can send the data to the client but not outside of the
call back.

Since I know that at any point only one client can communicate with a
server, so

1. Is the server client model in TCP/IP the correct choice, or is there
some other model like a peer-2-peer that I should be using
2. If the server client model is correct, then how do I do a tcp_write
outside the scope of a call back.

Regards
Amit
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

[lwip-users] Compilations errors with MEM_USE_POOLS

2015-11-05 Thread Andy Pont
Hello,

As I don't have access to a C library malloc() function I tried making a
call to mem_malloc() elsewhere in the project outside of the lwIP source
tree.  That call hangs and I am in the process of debugging it.  

As a quick alternative I thought I would define MEM_USE_POOLS as 1 in
lwipopts.h and see if that made things easier (or worked) but it gives
compilation errors:

net/lwIP/src/include/lwip/memp.h(64): Error! E1063: Missing operand
net/lwIP/src/include/lwip/memp.h(73): Error! E1063: Missing operand

Not sure what is going on with the compilation error but the comments around
the definition of the enum in memp.h use _START and _END but the actual code
uses _FIRST and _LAST.

Could someone clue me in as to what I am missing?

Thanks,

Andy.


___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users