[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [lwip-users] fundamentally flawed attempt at a TCP send
From: |
sirnails |
Subject: |
RE: [lwip-users] fundamentally flawed attempt at a TCP send |
Date: |
Thu, 17 Sep 2009 07:47:32 -0700 (PDT) |
Thanks for your reply Bill,
I have modified the code a little and now I am getting weird packets being
reported from wireshark; my new code:
> 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;
>
> pcb = tcp_new();
> tcp_bind(pcb, NULL, 44444);
> result = tcp_connect(pcb,boardip,55555,foobar);
> }
>
I think it may be something to do with the callback "foobar" im not sure
about the "void *arg" part, if anyone can clarify I would be very great full
to you!
Thanks in advance for any help!
Dave xx
Bill Auerbach wrote:
>
> First, the ip address isn't a constant, but a struct ip_addr *. Your code
> may well compile, but you should observe and correct the warnings. The
> last
> parameter to tcp_connect should simply be the name of the function which
> lwIP will callback when the connection is made. This is should not be a
> function call. The tcp_write would occur after you are notified of the
> connection (by the callback to tcp_connect).
>
>
>
> Bill
>
>
>
> From: address@hidden
> [mailto:address@hidden On Behalf
> Of sirnails
> Sent: Wednesday, September 16, 2009 11:13 AM
> To: address@hidden
> Subject: [lwip-users] fundamentally flawed attempt at a TCP send
>
>
>
> Hello All,
> I am trying to send a string over TCP and believe i am having fundamental
> understanding problems...
> The code i am trying to cobble together (based upon
> http://www.nongnu.org/lwip/) is:
>
> _____
>
> struct tcp_pcb *pcb;
>
> static char indexdata[] = "DAVE";
>
> pcb = tcp_new();
> tcp_bind(pcb, NULL, 44444);
> tcp_connect(pcb,0xC0A821AF,55555,tcp_write(pcb, indexdata,
> sizeof(indexdata), 1));
>
> tcp_close(pcb);
>
> _____
>
> a few questions:
> - what is a PCB (Protocol Control Block) and what is it for? is it just a
> unique reference number for the specific connection?
>
> - the code compiles correctly but when run gives a SIGSEGV fault :
>
> _____
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x02005d48 in tcp_connect (pcb=0x2013d90, ipaddr=0xc0a821af, port=55555,
> connected=0xfffffffa) at ../lwip/src/core/tcp.c:425
> 425 pcb->remote_ip = *ipaddr;
>
> _____
>
> Im sorry to be asking such a stupid question, I hope you can help!
> Dave xx
>
> _____
>
> View this message in context: fundamentally
> <http://www.nabble.com/fundamentally-flawed-attempt-at-a-TCP-send-tp25474522
> p25474522.html> flawed attempt at a TCP send
> Sent from the lwip-users <http://www.nabble.com/lwip-users-f7923.html>
> mailing list archive at Nabble.com.
>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>
--
View this message in context:
http://www.nabble.com/fundamentally-flawed-attempt-at-a-TCP-send-tp25474522p25491925.html
Sent from the lwip-users mailing list archive at Nabble.com.