[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] LWIP Client code help
From: |
shettys |
Subject: |
[lwip-users] LWIP Client code help |
Date: |
Sat, 23 Jun 2012 14:19:19 -0700 (PDT) |
Hello I have been stuck with some LWIP client code i was working on , using
RAW api. Was hoping someone could help me since i dont seem to be
understanding the reason.
I connect as a client to the server using the code mentioned below. Which it
does. And sends a message the first time.
I want to keep this connection and send messages without having to
disconnect. Could someone please tell me why i have to close the connection
and open it again every time to send a message?
err_t connect(void)
{
u8_t *state;
err_t err;
struct tcp_pcb *pcb;
struct ip_addr ipaddr;
IP4_ADDR(&ipaddr, 192,168,5,2);
if ((state = mem_malloc(1)) == NULL)
return ERR_MEM;
*state = 1;
if ((pcb = tcp_new()) == NULL)
{
mem_free(state);
return ERR_MEM;
}
tcp_arg(pcb, state);
tcp_err(pcb, hello_err);
tcp_recv(pcb, hello_recv);
tcp_sent(pcb, NULL);
tcp_poll(pcb, hello_poll_close, 10);
err = tcp_connect(pcb, &ipaddr, 7, connected);
if (err != ERR_OK)
{
mem_free(state);
tcp_abort(pcb);
}
return err;
}
err_t connected(void *arg, struct tcp_pcb *pcb, err_t err)
{
tcp_write(pcb, "my message", 12, 0);
return ERR_OK;
}
--
View this message in context:
http://old.nabble.com/LWIP-Client-code-help-tp34060222p34060222.html
Sent from the lwip-users mailing list archive at Nabble.com.