NetBurner 3.5.6
PDF Version
tcp.h File Reference

NetBurner TCP/IP socket 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)
 Operation completed successfully with no errors.
 
#define TCP_ERR_TIMEOUT   (-1)
 Operation timed out before completion.
 
#define TCP_ERR_NOCON   (-2)
 No active connection exists on this socket.
 
#define TCP_ERR_CLOSING   (-3)
 Socket is currently in the closing state.
 
#define TCP_ERR_NOSUCH_SOCKET   (-4)
 The specified socket does not exist.
 
#define TCP_ERR_NONE_AVAIL   (-5)
 No sockets available in the system pool.
 
#define TCP_ERR_CON_RESET   (-6)
 Connection was reset by remote host.
 
#define TCP_ERR_CON_ABORT   (-7)
 Connection was aborted.
 
#define SO_DEBUG   1
 Reserved for debugging purposes.
 
#define SO_NONAGLE   2
 Disable Nagle's algorithm (send data immediately without delay)
 
#define SO_NOPUSH   4
 Disable TCP PUSH flag (buffer data before sending)
 
#define TCP_STATE_CLOSED   (0)
 Socket is closed, no connection exists.
 
#define TCP_STATE_LISTEN   (1)
 Socket is listening for incoming connections.
 
#define TCP_STATE_SYN_SENT   (2)
 SYN packet sent, waiting for SYN-ACK.
 
#define TCP_STATE_SYN_RCVD   (3)
 SYN received, SYN-ACK sent.
 
#define TCP_STATE_WAIT_FOR_ACCEPT   (4)
 Connection pending, waiting for accept() call.
 
#define TCP_STATE_ESTABLISHED   (5)
 Connection established, data transfer possible.
 
#define TCP_STATE_CLOSE_WAIT   (6)
 FIN received from remote host, local close pending.
 
#define TCP_STATE_LAST_ACK   (7)
 FIN sent, waiting for final ACK.
 
#define TCP_STATE_FIN_WAIT_1   (8)
 Local FIN sent, waiting for ACK.
 
#define TCP_STATE_FIN_WAIT_2   (9)
 Local FIN acknowledged, waiting for remote FIN.
 
#define TCP_STATE_CLOSING   (10)
 Both sides closing simultaneously.
 
#define TCP_STATE_TIME_WAIT   (11)
 Connection closed, waiting to ensure remote received final ACK.
 

Typedefs

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

Functions

int accept (int listening_socket, IPADDR *address, uint16_t *port, uint16_t timeout)
 Accept an incoming connection on a listening socket.
 
int accept (int listening_socket, IPADDR *address, uint16_t *port, TickTimeout &timeout)
 Accept an incoming connection on a listening socket with timeout object.
 
int connect (const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout)
 Establish a TCP connection to a remote host.
 
int connectvia (const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, const IPADDR &localIpAddress)
 Establish a TCP connection using a specific local interface IP address.
 
int connectvia (const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, int ifnum)
 Establish a TCP connection using a specific local interface number.
 
int connectwlocal (const IPADDR &ipAddress, uint16_t localPort, uint16_t remotePort, uint32_t timeout, const IPADDR &localIpAddress=IPADDR::NullIP(), int intf=-1)
 Establish a TCP connection with full control over local parameters.
 
int listen (const IPADDR &addr, uint16_t port, uint8_t maxpend=5)
 Create a listening socket to accept incoming TCP connections.
 
int listenvia (const IPADDR &addr, uint16_t port, int ifn, uint8_t maxpend=5)
 Create a listening socket on a specific network interface.
 
int listenvia (const IPADDR &addr, uint16_t port, const IPADDR &localIpAddress, uint8_t maxpend=5)
 Create a listening socket bound to a specific interface IP address.
 
int NoBlockConnect (const IPADDR &ipAddress, uint16_t remotePort)
 Initiate a non-blocking TCP connection.
 
int NoBlockConnectVia (const IPADDR &ipAddress, uint16_t remotePort, const IPADDR &interfaceIpAddress=IPADDR::NullIP())
 Initiate a non-blocking TCP connection via a specific interface.
 
int NoBlockConnectVia (const IPADDR &ipAddress, uint16_t remotePort, int ifnum)
 Initiate a non-blocking TCP connection via a specific interface number.
 
int NoBlockConnectwlocal (const IPADDR &ipAddress, uint16_t localPort, uint16_t remotePort, IPADDR interfaceIpAddress=IPADDR::NullIP(), int ifn=-1)
 Initiate a non-blocking TCP connection with full local parameter control.
 
IPADDR GetSocketRemoteAddr (int fd)
 Get the remote host IP address for a socket connection.
 
IPADDR GetSocketLocalAddr (int fd)
 Get the local interface IP address for a socket connection.
 
uint16_t GetSocketRemotePort (int fd)
 Get the remote host port number for a socket connection.
 
uint16_t GetSocketLocalPort (int fd)
 Get the local port number for a socket connection.
 
uint32_t TcpGetLastRxTime (int fd)
 Get the system tick count when the last packet was received.
 
void TcpSendKeepAlive (int fd)
 Send a TCP keepalive probe packet.
 
uint32_t TcpGetLastRxInterval (int fd)
 Get the time elapsed since the last received packet.
 
int GetTcpRtxCount (int fd)
 Get the number of TCP retransmissions on a socket.
 
uint8_t SetOutOfOrderBuffers (int fd, uint8_t max)
 Configure the maximum number of out-of-order buffers for a TCP socket.
 
int setsockoption (int fd, int option)
 Enable TCP socket options.
 
int clrsockoption (int fd, int option)
 Disable TCP socket options.
 
int getsockoption (int fd)
 Query current TCP socket options.
 
int SetSocketUnackBuffers (int fd, uint8_t val)
 Configure the maximum number of unacknowledged transmit buffers.
 
int SetSocketRxBuffers (int fd, int n)
 Configure the number of TCP receive buffers.
 
int SetSocketTxBuffers (int fd, int n)
 Configure the number of TCP transmit buffers.
 
int abortsocket (int fd)
 Abort a TCP connection immediately.
 
int SockReadWithTimeout (int fd, char *buf, int nbytes, uint32_t timeout)
 Read from a TCP socket with a timeout.
 
char SocketPeek (int fd)
 Peek at the next available byte without removing it from the receive buffer.
 
int TcpGetSocketInterface (int fd)
 Get the network interface number associated with a TCP socket.
 
uint8_t TcpGetSocketState (int fd)
 Get the current TCP state of a socket.
 
uint16_t TcpGetRxBufferSpaceUsed (int fd)
 Get the number of bytes currently in the receive buffer.
 
uint16_t TcpGetTxBufferAvailSpace (int fd)
 Get the available space in the transmit buffer.
 
uint16_t TcpGetTxDataWaiting (int fd)
 Get the number of bytes queued for transmission.
 
BOOL TcpAllDataAcked (int socket)
 Check if all transmitted data has been acknowledged.
 
BOOL WaitForSocketFlush (int fd, uint32_t ticks)
 Wait for all transmitted data to be acknowledged.
 
void RegisterTCPReadNotify (int tcpFd, tcp_notify_handler *notifyHandler)
 Register a callback for read event notifications.
 
void RegisterTCPWriteNotify (int tcpFd, tcp_notify_handler *notifyHandler)
 Register a callback for write event notifications.
 

Detailed Description

NetBurner TCP/IP socket API.

Provides a comprehensive interface for TCP socket operations including connection management, data transfer, and socket configuration.