lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] fundamentally flawed attempt at a TCP send


From: Kieran Mansley
Subject: RE: [lwip-users] fundamentally flawed attempt at a TCP send
Date: Thu, 17 Sep 2009 15:56:51 +0100

On Thu, 2009-09-17 at 07:47 -0700, sirnails wrote:
> Thanks for your reply Bill,
> 
> I have modified the code a little and now I am getting weird packets being
> reported from wireshark; 

It would help if you could us the wireshark trace then, however I think
your problem is more simple than that (see below)...

> > struct tcp_pcb *pcb;
> > 
> > err_t foobar(void *arg, struct tcp_pcb *pcb, err_t err)
> > {
> >     static char data[] = "DAVE";
> >     tcp_write(pcb, data, sizeof(data),0);
> >     tcp_output(pcb);
> >     tcp_close(pcb);
> >     return ERR_OK;
> > }
> >                                                                             
> > void dave_init(void)                                                /* The 
> > initialization function. */
> > {
> >     //0xC0A821AF;
> >     struct ip_addr *boardip;
> >     err_t result;
> >     
> >     boardip->addr = 0xC0A82199;

You're making some basic C errors.  You've declared boardip as a pointer
and are then dereferencing it before giving the pointer a value.  I'm
surprised this didn't just segfault when you ran it.  This sort of thing
isn't lwIP specific.  There are lots of tutorials on C, pointers,
functions etc on the web if you need to read up on that.  I would change
the above to be:

struct ip_addr boardip;
boardip.addr = 0xC0A82199;

then when you call tcp_connect give it the address of boardip (i.e.
&boardip) as the IP address argument.  

Kieran





reply via email to

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