26.12.2013 Views

lwIP - A Minimal TCP/IP implementation - Wikia

lwIP - A Minimal TCP/IP implementation - Wikia

lwIP - A Minimal TCP/IP implementation - Wikia

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

18 CODE EXAMPLES 18.2 Directly interfacing the stack<br />

}<br />

/* Close the connection. */<br />

tcp_close(pcb);<br />

/* This is the callback function that is called when<br />

a connection has been accepted. */<br />

static void<br />

http_accept(void *arg, struct tcp_pcb *pcb)<br />

{<br />

/* Set up the function http_recv() to be called when data<br />

arrives. */<br />

tcp_recv(pcb, http_recv, NULL);<br />

}<br />

/* The initialization function. */<br />

void<br />

http_init(void)<br />

{<br />

struct tcp_pcb *pcb;<br />

}<br />

/* Create a new <strong>TCP</strong> PCB. */<br />

pcb = tcp_pcb_new();<br />

/* Bind the PCB to <strong>TCP</strong> port 80. */<br />

tcp_bind(pcb, NULL, 80);<br />

/* Change <strong>TCP</strong> state to LISTEN. */<br />

tcp_listen(pcb);<br />

/* Set up http_accet() function to be called<br />

when a new connection arrives. */<br />

tcp_accept(pcb, http_accept, NULL);<br />

40

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!