NetBurner 3.3.4
PDF Version
tcp.h File Reference

NetBurner TCP API. More...

#include <predef.h>
#include <ip.h>
#include <nettypes.h>
#include <tcp_private.h>

Go to the source code of this file.

Macros

#define TCP_ERR_NORMAL   (0)
 No errors.
 
#define TCP_ERR_TIMEOUT   (-1)
 Socket timed out.
 
#define TCP_ERR_NOCON   (-2)
 No connection exists.
 
#define TCP_ERR_CLOSING   (-3)
 Socket is in the process of closing.
 
#define TCP_ERR_NOSUCH_SOCKET   (-4)
 No such socket exists.
 
#define TCP_ERR_NONE_AVAIL   (-5)
 No new sockets are available.
 
#define TCP_ERR_CON_RESET   (-6)
 Connection has been reset.
 
#define TCP_ERR_CON_ABORT   (-7)
 Connection has been aborted.
 
#define SO_DEBUG   1
 Reserved.
 
#define SO_NONAGLE   2
 Disable the Nagle algorithm.
 
#define SO_NOPUSH   4
 Disable TCP PUSH feature.
 
#define TCP_STATE_CLOSED   (0)
 Socket Closed.
 
#define TCP_STATE_LISTEN   (1)
 Listen Socket.
 
#define TCP_STATE_SYN_SENT   (2)
 Packet with synchronization flag sent.
 
#define TCP_STATE_SYN_RCVD   (3)
 Packet with synchronisation flag received.
 
#define TCP_STATE_WAIT_FOR_ACCEPT   (4)
 Socket waiting for accept.
 
#define TCP_STATE_ESTABLISHED   (5)
 TCP session established.
 
#define TCP_STATE_CLOSE_WAIT   (6)
 FIN received from client and socet is in the process of closing.
 
#define TCP_STATE_LAST_ACK   (7)
 Server is in the process of sending its own FIN signal.
 
#define TCP_STATE_FIN_WAIT_1   (8)
 Connection is active but not currently being used.
 
#define TCP_STATE_FIN_WAIT_2   (9)
 Client has received first ACK of the first FIN signal from server.
 
#define TCP_STATE_CLOSING   (10)
 Session is closing, but data may still be processed.
 
#define TCP_STATE_TIME_WAIT   (11)
 Client recognizes connection still open, but not currently being used.
 

Typedefs

typedef void() tcp_notify_handler(int tcpFd)
 TCP notification callback type. More...
 

Functions

int accept (int listening_socket, IPADDR *address, uint16_t *port, uint16_t timeout)
 Accept an incoming connection from a listening socket. More...
 
int connect (const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout)
 Make an outgoing TCP connection to a remote host. More...
 
int connectvia (const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, const IPADDR &localIpAddress)
 Make an outgoing TCP connection to a remote host using the specified local interface IP address. More...
 
int connectvia (const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, int ifnum)
 Make an outgoing TCP connection to a remote host using the specified local interface number. More...
 
int connectwlocal (const IPADDR &ipAddress, uint16_t localPort, uint16_t remotePort, uint32_t timeout, const IPADDR &localIpAddress=IPADDR::NullIP(), int intf=-1)
 Make an outgoing TCP connection to a remote host using the specified local interface number or IP address. More...
 
int listen (const IPADDR &addr, uint16_t port, uint8_t maxpend=5)
 Listen for incoming connections on the specified network interface IP address. More...
 
int listenvia (const IPADDR &addr, uint16_t port, int ifn, uint8_t maxpend=5)
 Listen for incoming connections on the specified network interface IP address. More...
 
int listenvia (const IPADDR &addr, uint16_t port, const IPADDR &localIpAddress, uint8_t maxpend=5)
 Listen for incoming connections on the specified network interface IP address. More...
 
int NoBlockConnect (const IPADDR &ipAddress, uint16_t remotePort)
 Create a file descriptor for a TCP connection and return immediately. This function does not wait for a connection to be established. Before using the file descriptor, the application must verify the connection was successful with TcpGetSocketState(fd). The state will be TCP_STATE_ESTABLISHED when the connection has been successfully established. Note: The connection status can also be obtained with the wireavail() function. More...
 
int NoBlockConnectVia (const IPADDR &ipAddress, uint16_t remotePort, const IPADDR &interfaceIpAddress=IPADDR::NullIP())
 Create a file descriptor for a TCP connection and return immediately. This function does not wait for a connection to be established. Before using the file descriptor, the application must verify the connection was successful with TcpGetSocketState(fd). The state will be TCP_STATE_ESTABLISHED when the connection has been successfully established. Note: The connection status can also be obtained with the wireavail() function. More...
 
int NoBlockConnectVia (const IPADDR &ipAddress, uint16_t remotePort, int ifnum)
 Create a file descriptor for a TCP connection and return immediately. This function does not wait for a connection to be established. Before using the file descriptor, the application must verify the connection was successful with TcpGetSocketState(fd). The state will be TCP_STATE_ESTABLISHED when the connection has been successfully established. Note: The connection status can also be obtained with the wireavail() function. More...
 
int NoBlockConnectwlocal (const IPADDR &ipAddress, uint16_t localPort, uint16_t remotePort, IPADDR interfaceIpAddress=IPADDR::NullIP(), int ifn=-1)
 Create a file descriptor for a TCP connection and return immediately. This function does not wait for a connection to be established. Before using the file descriptor, the application must verify the connection was successful with TcpGetSocketState(fd). The state will be TCP_STATE_ESTABLISHED when the connection has been successfully established. Note: The connection status can also be obtained with the wireavail() function. More...
 
IPADDR GetSocketRemoteAddr (int fd)
 Returns the IP address of the remote host associated with the specified file descriptor. More...
 
IPADDR GetSocketLocalAddr (int fd)
 Returns the IP address of the local interface associated with the connection. More...
 
uint16_t GetSocketRemotePort (int fd)
 Returns the port number of the remote host associated with the connection. More...
 
uint16_t GetSocketLocalPort (int fd)
 Returns the local port number associated with the connection. More...
 
uint32_t TcpGetLastRxTime (int fd)
 Returns the value of system Time Ticks when the last packet was received. Used for the TCP Keep Alive feature. More...
 
void TcpSendKeepAlive (int fd)
 Send a TCP keep alive packet to a remote host. More...
 
uint32_t TcpGetLastRxInterval (int fd)
 Returns the number of system Time Ticks since the last packet was received. This is the difference between the current system time and lastRxTime of the socket. More...
 
int GetTcpRtxCount (int fd)
 Returns the number of re-transmits that have occurred on the specified connection. More...
 
uint8_t SetOutOfOrderBuffers (int fd, uint8_t max)
 Set the maximum number of out-of-order TCP buffers for the specified TCP socket. More...
 
int setsockoption (int fd, int option)
 Set TCP socket options. More...
 
int clrsockoption (int fd, int option)
 Clear TCP socket options. More...
 
int getsockoption (int fd)
 Returns the options for the specified TCP socket. More...
 
int SetSocketUnackBuffers (int fd, uint8_t val)
 Set the maximum number of outbound TCP buffers in the transmit un-acknowledged list for the specified TCP socket. More...
 
int SetSocketRxBuffers (int fd, int n)
 Set the number of TCP receive buffers for the specified TCP socket. More...
 
int SetSocketTxBuffers (int fd, int n)
 Set the number of TCP transmit buffers for the specified TCP socket. More...
 
int abortsocket (int fd)
 Execute an abort on the specified TCP socket. More...
 
int SockReadWithTimeout (int fd, char *buf, int nbytes, uint32_t timeout)
 Attempt to read from a TCP socket until the timeout expires. More...
 
char SocketPeek (int fd)
 Returns the next char that would be read, 0 if no data. More...
 
int TcpGetSocketInterface (int fd)
 Return the network interface associated with a TCP socket. More...
 
uint8_t TcpGetSocketState (int fd)
 Return the current state of a TCP socket. More...
 
uint16_t TcpGetRxBufferSpaceUsed (int fd)
 Returns the number of bytes used in a socket's RX buffer. More...
 
uint16_t TcpGetTxBufferAvailSpace (int fd)
 Returns the number of bytes available in a socket's TX buffer. More...
 
BOOL TcpAllDataAcked (int socket)
 Check the data acknowledged state of a socket. More...
 
BOOL WaitForSocketFlush (int fd, uint32_t ticks)
 Wait for a socket flush operation to complete. A socket is flushed if all sent data has been acknowledged. More...
 
void RegisterTCPReadNotify (int tcpFd, tcp_notify_handler *notifyHandler)
 Register a TCP socket and callback function for read notifications. More...
 
void RegisterTCPWriteNotify (int tcpFd, tcp_notify_handler *notifyHandler)
 Register a TCP socket and callback function for write notifications. More...
 

Detailed Description

NetBurner TCP API.