TCP-lwip - Wikia Technology Create a new wiki Log in Create...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Wikia Technology Create a new wiki Log in Create an account lwIP Wiki Edit this page History Share this article Article Discussion Raw/TCP From lwIP Wiki
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object 1
Background image of page 2
Contents [ hide ] 1 Initializ ation 2 TCP connect ion setup 2 . 1 P a s s i v e c o n n e c t i o n ( L i s t e n ) 2 . 2 A c t i v
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
edit Initialization lwip_init() must be called before any tcp functions are called. void tcp_tmr(void) After lwip_init() is called, you must call tcp_tmr() every TCP_TMR_INTERVAL milliseconds (default is 250 milliseconds). edit TCP connection setup A TCP connection is identified by a protocol control block (PCB). There are two ways to set up a connection. [ edit ] Passive connection (Listen) 1. Call tcp_new to create a pcb. 2. Call tcp_bind to specify the local IP address and port. 3. Call tcp_listen or tcp_listen_with_backlog. 4. Call tcp_accept to specify the function to be called when a new connection arrives. [ edit ] Active connection 1. Call tcp_new to create a pcb. 2. Optionally call tcp_bind to specify the local IP address and port. 3. Call tcp_connect. edit TCP connection functions struct tcp_pcb * tcp_new(void) Creates a new connection control block (PCB). The connection is initially in the "closed" state. If memory is not available for creating the new pcb, NULL is returned. void tcp_arg(struct tcp_pcb * pcb, void * arg) The "pcb" argument specifies a TCP connection control block, and the "arg" argument is the argument that will be passed to all the callbacks for that connection. This argument can be used by the application for any purpose. err_t tcp_bind(struct tcp_pcb * pcb, struct ip_addr * ipaddr, u16_t port) Binds the pcb to a local IP address and port number. The IP address can be specified as IP_ADDR_ANY in order to bind the connection to all local IP addresses. If the port is specified as zero, the function selects an available port. The connection must be in the "closed" state. If another connection is bound to the same port, the function will return ERR_USE, otherwise ERR_OK is Object 2 Object 3
Background image of page 4
returned. struct tcp_pcb * tcp_listen(struct tcp_pcb * pcb) The "pcb" parameter specifies a connection, which must be in the "closed" state and must have been bound to a local port with the tcp_bind() function. This functions sets up the local port to listen for incoming connections. The tcp_listen() function returns a new connection control block, and the one passed as an argument to the function will be deallocated. The reason for this behavior is that less memory is needed for a connection that is listening, so tcp_listen() will reclaim the memory needed for the original connection and allocate a new smaller memory block for the listening connection. After calling tcp_listen(), you must call tcp_accept(). Until you do so, incoming connections for this port will
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/11/2009 for the course CSE CS taught by Professor Crm during the Spring '08 term at Indian Institute of Technology, Kharagpur.

Page1 / 19

TCP-lwip - Wikia Technology Create a new wiki Log in Create...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online