Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Examples

Network functions


Modules

 The uIP TCP/IP stack
 The uIP TCP/IP stack provides Internet communication abilities to Contiki.
 Protosockets library
 The protosocket library provides an interface to the uIP stack that is similar to the traditional BSD socket interface.
 The Contiki/uIP interface
 TCP/IP support in Contiki is implemented using the uIP TCP/IP stack.

TCP functions

#define tcp_markconn(conn, appstate)   tcp_attach(conn, appstate)
void tcp_attach (struct uip_conn *conn, void *appstate)
 Attach a TCP connection to the current process.
void tcp_listen (u16_t port)
 Open a TCP port.
void tcp_unlisten (u16_t port)
 Close a listening TCP port.
uip_conntcp_connect (u16_t *ripaddr, u16_t port, void *appstate)
 Open a TCP connection to the specified IP address and port.
void tcpip_poll_tcp (struct uip_conn *conn)
 Cause a specified TCP connection to be polled.


Function Documentation

void tcp_attach struct uip_conn conn,
void *  appstate
 

Attach a TCP connection to the current process.

This function attaches the current process to a TCP connection. Each TCP connection must be attached to a process in order for the process to be able to receive and send data. Additionally, this function can add a pointer with connection state to the connection.

Parameters:
conn A pointer to the TCP connection.
appstate An opaque pointer that will be passed to the process whenever an event occurs on the connection.

Definition at line 169 of file tcpip.c.

References uip_conn::appstate, tcpip_uipstate::p, PROCESS_CURRENT, and tcpip_uipstate::state.

struct uip_conn* tcp_connect u16_t *  ripaddr,
u16_t  port,
void *  appstate
 

Open a TCP connection to the specified IP address and port.

This function opens a TCP connection to the specified port at the host specified with an IP address. Additionally, an opaque pointer can be attached to the connection. This pointer will be sent together with uIP events to the process.

Note:
The port number must be provided in network byte order so a conversion with HTONS() usually is necessary.

This function will only create the connection. The connection is not opened directly. uIP will try to open the connection the next time the uIP stack is scheduled by Contiki.

Parameters:
ripaddr Pointer to the IP address of the remote host.
port Port number in network byte order.
appstate Pointer to application defined data.
Returns:
A pointer to the newly created connection, or NULL if memory could not be allocated for the connection.

Definition at line 115 of file tcpip.c.

References uip_conn::appstate, NULL, tcpip_uipstate::p, PROCESS_CURRENT, tcpip_uipstate::state, tcpip_poll_tcp(), and uip_connect().

void tcp_listen u16_t  port  ) 
 

Open a TCP port.

This function opens a TCP port for listening. When a TCP connection request occurs for the port, the process will be sent a tcpip_event with the new connection request.

Note:
Port numbers must always be given in network byte order. The functions HTONS() and htons() can be used to convert port numbers from host byte order to network byte order.
Parameters:
port The port number in network byte order.
Examples:
example-psock-server.c.

Definition at line 151 of file tcpip.c.

References PROCESS_CURRENT, uip_listen(), and UIP_LISTENPORTS.

void tcp_unlisten u16_t  port  ) 
 

Close a listening TCP port.

This function closes a listening TCP port.

Note:
Port numbers must always be given in network byte order. The functions HTONS() and htons() can be used to convert port numbers from host byte order to network byte order.
Parameters:
port The port number in network byte order.

Definition at line 133 of file tcpip.c.

References PROCESS_CURRENT, UIP_LISTENPORTS, and uip_unlisten().

void tcpip_poll_tcp struct uip_conn conn  ) 
 

Cause a specified TCP connection to be polled.

This function causes uIP to poll the specified TCP connection. The function is used when the application has data that is to be sent immediately and do not wish to wait for the periodic uIP polling mechanism.

Parameters:
conn A pointer to the TCP connection that should be polled.

Definition at line 346 of file tcpip.c.

References process_post().

Referenced by tcp_connect().


Generated on Thu Jun 22 17:45:43 2006 for Contiki 2.x by  doxygen 1.4.4