NetBurner 3.5.6
PDF Version
tcp.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
13#ifndef _NB_TCP_H
14#define _NB_TCP_H
15
16#include <predef.h>
17#include <ip.h>
18#include <nettypes.h>
19#include <tcp_private.h>
20
21#ifndef IPV6
22#ifndef IPV4ONLY
23#error Must select an IP version in tcp.h
24#endif
25#endif
26
27#ifdef IPV6
28#ifdef IPV4ONLY
29#error Must select IPV4ONLY or IPV6 but not both
30#endif
31#endif
32
33
354#define TCP_ERR_NORMAL (0)
355#define TCP_ERR_TIMEOUT (-1)
356#define TCP_ERR_NOCON (-2)
357#define TCP_ERR_CLOSING (-3)
358#define TCP_ERR_NOSUCH_SOCKET (-4)
359#define TCP_ERR_NONE_AVAIL (-5)
360#define TCP_ERR_CON_RESET (-6)
361#define TCP_ERR_CON_ABORT (-7)
542 int accept(int listening_socket, IPADDR *address, uint16_t *port, uint16_t timeout);
543
544#ifdef IPV6
545int accept4(int listening_socket, IPADDR4 *address, uint16_t *port, uint16_t timeout);
546#define accept6 accept
547#else
548#define accept4 accept
549#endif
550
551
1031int accept(int listening_socket, IPADDR *address, uint16_t *port, TickTimeout &timeout);
1032
1033
1034
1547inline int connect(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout)
1548{
1549 TickTimeout tt(timeout);
1550 return CoreConnect(ipAddress, 0, remotePort, tt, IPADDR::NullIP(), -1);
1551};
1552
1553
1554
1555
2044inline int connectvia(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, const IPADDR &localIpAddress)
2045{
2046 TickTimeout tt(timeout);
2047 return CoreConnect(ipAddress, 0, remotePort, tt, localIpAddress, -1);
2048};
2049
2692inline int connectvia(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, int ifnum)
2693{
2694 TickTimeout tt(timeout);
2695 return CoreConnect(ipAddress, 0, remotePort, tt, IPADDR::NullIP(), ifnum);
2696};
2697
2698
2699
3261inline int connectwlocal(const IPADDR &ipAddress,
3262 uint16_t localPort,
3263 uint16_t remotePort,
3264 uint32_t timeout,
3265 const IPADDR &localIpAddress = IPADDR::NullIP(),
3266 int intf = -1)
3267{
3268 TickTimeout tt(timeout);
3269 return CoreConnect(ipAddress, localPort, remotePort, tt, localIpAddress, intf);
3270};
3271
3272
3273
3274#ifdef IPV6
3275 inline int connect6(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout)
3276 {
3277 TickTimeout tt(timeout);
3278 return CoreConnect(ipAddress, 0, remotePort, tt, IPADDR::NullIP(), -1);
3279 };
3280 inline int connectvia6(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, const IPADDR &localIpAddress)
3281 {
3282 TickTimeout tt(timeout);
3283 return CoreConnect(ipAddress, 0, remotePort, tt, localIpAddress, -1);
3284 };
3285 inline int connectvia6(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, int ifnum)
3286 {
3287 TickTimeout tt(timeout);
3288 return CoreConnect(ipAddress, 0, remotePort, tt, IPADDR::NullIP(), ifnum);
3289 };
3290 inline int connectwlocal6(const IPADDR &ipAddress,
3291 uint16_t localPort,
3292 uint16_t remotePort,
3293 uint32_t timeout,
3294 const IPADDR &localIpAddress = IPADDR::NullIP(),
3295 int ifn = -1)
3296 {
3297 TickTimeout tt(timeout);
3298 return CoreConnect(ipAddress, localPort, remotePort, tt, localIpAddress, ifn);
3299 };
3300
3301 inline int connect4(IPADDR4 ipAddress, uint16_t remotePort, uint32_t timeout)
3302 {
3303 TickTimeout tt(timeout);
3304 return CoreConnect4(ipAddress, 0, remotePort, tt, IPADDR4::NullIP(), -1);
3305 };
3306 inline int connectvia4(IPADDR4 ipAddress, uint16_t remotePort, uint32_t timeout, IPADDR4 localIpAddress)
3307 {
3308 TickTimeout tt(timeout);
3309 return CoreConnect4(ipAddress, 0, remotePort, tt, localIpAddress, -1);
3310 };
3311 inline int connectvia4(IPADDR4 ipAddress, uint16_t remotePort, uint32_t timeout, int ifnum)
3312 {
3313 TickTimeout tt(timeout);
3314 return CoreConnect4(ipAddress, 0, remotePort, tt, IPADDR4::NullIP(), ifnum);
3315 };
3316 inline int connectwlocal4(IPADDR4 ipAddress,
3317 uint16_t localPort,
3318 uint16_t remotePort,
3319 uint32_t timeout,
3320 IPADDR4 localIpAddress = IPADDR4::NullIP(),
3321 int ifn = -1)
3322 {
3323 TickTimeout tt(timeout);
3324 return CoreConnect4(ipAddress, localPort, remotePort, tt, localIpAddress, ifn);
3325 };
3326#else
3327 #define connect4 connect
3328 #define connectvia4 connectvia
3329 #define connectwlocal4 connectwlocal
3330#endif
3331
3931inline int connect(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout)
3932{
3933 return CoreConnect(ipAddress, 0, remotePort, timeout, IPADDR::NullIP(), -1);
3934};
3935
3936
4651inline int connectvia(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout, const IPADDR &localIpAddress)
4652{
4653 return CoreConnect(ipAddress, 0, remotePort, timeout, localIpAddress, -1);
4654};
4655
4656
5381inline int connectvia(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout, int ifnum)
5382{
5383 return CoreConnect(ipAddress, 0, remotePort, timeout, IPADDR::NullIP(), ifnum);
5384};
5385
5386
5986inline int connectwlocal(const IPADDR &ipAddress,
5987 uint16_t localPort,
5988 uint16_t remotePort,
5989 TickTimeout timeout,
5990 const IPADDR &localIpAddress = IPADDR::NullIP(),
5991 int intf = -1)
5992{
5993 return CoreConnect(ipAddress, localPort, remotePort, timeout, localIpAddress, intf);
5994};
5995
5996
5997#ifdef IPV6
5998 inline int connect6(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout)
5999 {
6000 return CoreConnect(ipAddress, 0, remotePort, timeout, IPADDR::NullIP(), -1);
6001 };
6002 inline int connectvia6(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout, const IPADDR &localIpAddress)
6003 {
6004 return CoreConnect(ipAddress, 0, remotePort, timeout, localIpAddress, -1);
6005 };
6006 inline int connectvia6(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout, int ifnum)
6007 {
6008 return CoreConnect(ipAddress, 0, remotePort, timeout, IPADDR::NullIP(), ifnum);
6009 };
6010 inline int connectwlocal6(const IPADDR &ipAddress,
6011 uint16_t localPort,
6012 uint16_t remotePort,
6013 TickTimeout &timeout,
6014 const IPADDR &localIpAddress = IPADDR::NullIP(),
6015 int ifn = -1)
6016 {
6017 return CoreConnect(ipAddress, localPort, remotePort, timeout, localIpAddress, ifn);
6018 };
6019
6020 inline int connect4(IPADDR4 ipAddress, uint16_t remotePort, TickTimeout &timeout)
6021 {
6022 return CoreConnect4(ipAddress, 0, remotePort, timeout, IPADDR4::NullIP(), -1);
6023 };
6024 inline int connectvia4(IPADDR4 ipAddress, uint16_t remotePort, TickTimeout &timeout, IPADDR4 localIpAddress)
6025 {
6026 return CoreConnect4(ipAddress, 0, remotePort, timeout, localIpAddress, -1);
6027 };
6028 inline int connectvia4(IPADDR4 ipAddress, uint16_t remotePort, TickTimeout &timeout, int ifnum)
6029 {
6030 return CoreConnect4(ipAddress, 0, remotePort, timeout, IPADDR4::NullIP(), ifnum);
6031 };
6032 inline int connectwlocal4(IPADDR4 ipAddress,
6033 uint16_t localPort,
6034 uint16_t remotePort,
6035 TickTimeout &timeout,
6036 IPADDR4 localIpAddress = IPADDR4::NullIP(),
6037 int ifn = -1)
6038 {
6039 return CoreConnect4(ipAddress, localPort, remotePort, timeout, localIpAddress, ifn);
6040 };
6041#endif
6042
6629inline int listen(const IPADDR &addr, uint16_t port, uint8_t maxpend = 5)
6630{
6631 return CoreListen(addr, port, -1, IPADDR::NullIP(), maxpend);
6632};
6633
6634
7299inline int listenvia(const IPADDR &addr, uint16_t port, int ifn, uint8_t maxpend = 5)
7300{
7301 return CoreListen(addr, port, ifn, IPADDR::NullIP(), maxpend);
7302};
7303
7514inline int listenvia(const IPADDR &addr, uint16_t port, const IPADDR &localIpAddress, uint8_t maxpend = 5)
7515{
7516 return CoreListen(addr, port, -1, localIpAddress, maxpend);
7517};
7518
7519#ifdef IPV6
7520 inline int listen6(const IPADDR &addr, uint16_t port, uint8_t maxpend = 5)
7521 {
7522 return CoreListen(addr, port, -1, IPADDR::NullIP(), maxpend);
7523 };
7524
7525 inline int listenvia6(const IPADDR &addr, uint16_t port, int ifn, uint8_t maxpend = 5)
7526 {
7527 return CoreListen(addr, port, ifn, IPADDR::NullIP(), maxpend);
7528 };
7529
7530 inline int listenvia6(const IPADDR &addr, uint16_t port, const IPADDR &localIpAddress, uint8_t maxpend = 5)
7531 {
7532 return CoreListen(addr, port, -1, localIpAddress, maxpend);
7533 };
7534
7535 inline int listen4(IPADDR4 addr, uint16_t port, uint8_t maxpend = 5)
7536 {
7537 return CoreListen4(addr, port, -1, IPADDR4::NullIP(), maxpend);
7538 };
7539
7540 inline int listenvia4(IPADDR4 addr, uint16_t port, int ifn, uint8_t maxpend = 5)
7541 {
7542 return CoreListen(addr, port, ifn, IPADDR4::NullIP(), maxpend);
7543 };
7544
7545 inline int listenvia4(IPADDR4 addr, uint16_t port, IPADDR4 localIpAddress, uint8_t maxpend = 5)
7546 {
7547 return CoreListen4(addr, port, -1, localIpAddress, maxpend);
7548 };
7549#else
7550 #define listen4 listen
7551 #define listenvia4 listenvia
7552#endif
7553
7893inline int NoBlockConnect(const IPADDR &ipAddress, uint16_t remotePort)
7894{
7895 return NoBlockCoreConnect(ipAddress, 0, remotePort, IPADDR::NullIP(), -1);
7896};
7897
7898
7919inline int NoBlockConnectVia(const IPADDR &ipAddress, uint16_t remotePort, const IPADDR &interfaceIpAddress = IPADDR::NullIP())
7920{
7921 return NoBlockCoreConnect(ipAddress, 0, remotePort, interfaceIpAddress, -1);
7922};
7923
7924
8340inline int NoBlockConnectVia(const IPADDR &ipAddress, uint16_t remotePort, int ifnum)
8341{
8342 return NoBlockCoreConnect(ipAddress, 0, remotePort, IPADDR::NullIP(), ifnum);
8343};
8344
8345
8810inline int NoBlockConnectwlocal(const IPADDR &ipAddress,
8811 uint16_t localPort,
8812 uint16_t remotePort,
8813 IPADDR interfaceIpAddress = IPADDR::NullIP(),
8814 int ifn = -1)
8815{
8816 return NoBlockCoreConnect(ipAddress, localPort, remotePort, interfaceIpAddress, ifn);
8817};
8818
8819
8820#ifdef IPV6
8821 inline int NoBlockConnect6(const IPADDR &ipAddress, uint16_t remotePort)
8822 {
8823 return NoBlockCoreConnect(ipAddress, 0, remotePort, IPADDR::NullIP(), -1);
8824 };
8825
8826 inline int NoBlockConnectVia6(const IPADDR &ipAddress, uint16_t remotePort, const IPADDR &interfaceIpAddress = IPADDR::NullIP())
8827 {
8828 return NoBlockCoreConnect(ipAddress, 0, remotePort, interfaceIpAddress, -1);
8829 };
8830
8831 inline int NoBlockConnectVia6(const IPADDR &ipAddress, uint16_t remotePort, int ifnum)
8832 {
8833 return NoBlockCoreConnect(ipAddress, 0, remotePort, IPADDR::NullIP(), ifnum);
8834 };
8835
8836 inline int NoBlockConnectwlocal6(const IPADDR &ipAddress, uint16_t localPort, uint16_t remotePort, IPADDR interfaceIpAddress, int ifn = -1)
8837 {
8838 return NoBlockCoreConnect(ipAddress, localPort, remotePort, interfaceIpAddress, ifn);
8839 };
8840
8841 inline int NoBlockConnect4(const IPADDR4 &ipAddress, uint16_t remotePort, uint32_t timeout)
8842 {
8843 return NoBlockCoreConnect4(ipAddress, 0, remotePort, IPADDR4::NullIP(), -1);
8844 };
8845
8846 inline int NoBlockConnectVia4(const IPADDR4 &ipAddress, uint16_t remotePort, const IPADDR4 &interfaceIpAddress = IPADDR4::NullIP())
8847 {
8848 return NoBlockCoreConnect4(ipAddress, 0, remotePort, interfaceIpAddress, -1);
8849 };
8850
8851 inline int NoBlockConnectVia4(const IPADDR4 &ipAddress, uint16_t remotePort, int ifn)
8852 {
8853 return NoBlockCoreConnect4(ipAddress, 0, remotePort, IPADDR4::NullIP(), ifn);
8854 };
8855
8856 inline int NoBlockConnectwlocal4(const IPADDR4 &ipAddress,
8857 uint16_t localPort,
8858 uint16_t remotePort,
8859 const IPADDR4 &interfaceIpAddress,
8860 int ifn = -1)
8861 {
8862 return NoBlockCoreConnect4(ipAddress, localPort, remotePort, interfaceIpAddress, ifn);
8863 };
8864
8865#else
8866 #define NoBlockConnect4 NoBlockConnect
8867 #define NoBlockConnectVia4 NoBlockConnectVia
8868 #define NoBlockConnectwlocal4 NoBlockConnectwlocal
8869
8870#endif
8871
9317int getsocketerror(int fd);
9318
9319
9320/* Socket status functions */
9321IPADDR4 GetSocketRemoteAddr4(int fd);
9322IPADDR4 GetSocketLocalAddr4(int fd);
9323
9324#ifdef IPV6
9325 bool bRemoteAddrIsIpV6();
9326 bool bLocalAddrIsIpV6();
9327
9328 IPADDR GetSocketRemoteAddr6(int fd);
9329
9330 IPADDR GetSocketLocalAddr6(int fd);
9331
9394 {
9395 return GetSocketRemoteAddr6(fd);
9396 };
9397
9471 {
9472 return GetSocketLocalAddr6(fd);
9473 };
9474
9475#else
9476 inline IPADDR4 GetSocketRemoteAddr(int fd)
9477 {
9478 return GetSocketRemoteAddr4(fd);
9479 };
9480 inline IPADDR4 GetSocketLocalAddr(int fd)
9481 {
9482 return GetSocketLocalAddr4(fd);
9483 };
9484
9485#endif
9486
9553uint16_t GetSocketRemotePort(int fd);
9565uint16_t GetSocketLocalPort(int fd);
9566
9567
9568
9569/*------------------------------- Keepalive functions --------------------------------*/
9570
9571
9950uint32_t TcpGetLastRxTime(int fd);
9951
10186void TcpSendKeepAlive(int fd);
10187
10520uint32_t TcpGetLastRxInterval(int fd);
10521
10880int GetTcpRtxCount(int fd);
10881
10882
10883
10884uint8_t SetOutOfOrderbuffers(int fd, uint8_t max); // replaced with inline version below for lower case "buffers"
10885
11303inline uint8_t SetOutOfOrderBuffers(int fd, uint8_t max)
11304{
11305 return SetOutOfOrderbuffers(fd, max);
11306}
11307
11308
11309#if defined MULTIHOME || defined AUTOIP
11310
11311 int connectvia4(IPADDR4 addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, IPADDR4 ipa);
11312 int NoBlockconnectvia4(IPADDR4 addr, uint16_t localport, uint16_t remoteport, IPADDR4 ipa, int intfnum = -1);
11313 int connectvia4(IPADDR4 addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, int intfnum);
11314
11315 #ifdef IPV6
11316 int connectvia6(const IPADDR &addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, const IPADDR &ipa);
11317 inline int connectvia(const IPADDR &addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, const IPADDR &ipa)
11318 {
11319 return connectvia6(addr, localport, remoteport, timeout, ipa);
11320 };
11321
11322 int connectvia6(const IPADDR &addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, int intfnum);
11323 inline int connectvia(const IPADDR &addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, int intfnum)
11324 {
11325 return connectvia6(addr, localport, remoteport, timeout, intfnum);
11326 };
11327
11328 int NoBlockconnectvia6(IPADDR4 addr, uint16_t localport, uint16_t remoteport, const IPADDR &ipa);
11329 inline int NoBlockconnectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, const IPADDR &ipa)
11330 {
11331 return NoBlockconnectvia6(addr, localport, remoteport, ipa);
11332 };
11333
11334 int NoBlockconnectvia6(IPADDR4 addr, uint16_t localport, uint16_t remoteport, int intfnum);
11335 inline int NoBlockconnectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, int intfnum)
11336 {
11337 return NoBlockconnectvia6(addr, localport, remoteport, intfnum);
11338 };
11339 #else
11340 inline int connectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, IPADDR4 ipa)
11341 {
11342 return connectvia4(addr, localport, remoteport, timeout, ipa);
11343 };
11344
11345 inline int NoBlockconnectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, IPADDR4 ipa)
11346 {
11347 return NoBlockconnectvia4(addr, localport, remoteport, ipa);
11348 };
11349
11350 inline int connectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, int intfnum)
11351 {
11352 return connectvia4(addr, localport, remoteport, timeout, intfnum);
11353 };
11354
11355 inline int NoBlockconnectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, int intfnum)
11356 {
11357 return NoBlockconnectvia4(addr, localport, remoteport, intfnum);
11358 };
11359 #endif
11360#endif
11361
11362/* Get and set the socket options */
11363
11373#define SO_DEBUG 1
11374#define SO_NONAGLE 2
11375#define SO_NOPUSH 4
11681int setsockoption(int fd, int option);
11682
11922int clrsockoption(int fd, int option);
11923
12263int getsockoption(int fd);
12264
12265
12266
12267// Usae inline function below for camel case correction
12268int setsocketackbuffers(int fd, uint8_t val);
12269
12335inline int SetSocketUnackBuffers(int fd, uint8_t val)
12336{
12337 return setsocketackbuffers(fd, val);
12338}
12339
12418int SetSocketRxBuffers(int fd, int n);
12419
12506int SetSocketTxBuffers(int fd, int n);
12507
12508
12604int abortsocket(int fd);
12605
12737int SockReadWithTimeout(int fd, char *buf, int nbytes, uint32_t timeout);
12738
12871char SocketPeek(int fd);
12872
12965
13113void EnableTcpDebug(uint16_t dbFlags);
13114
13115
13116#ifdef SPEED_TCP
13117 typedef void(tcp_data_handler)(int fd, puint8_t data, uint16_t len);
13118 void RegisterDataProcessor(int fd, tcp_data_handler *pdh);
13119#endif
13120
13121
13284
13285
13286
13287/* TCP socket states RFC 793 (Do not change) */
13288
13301#define TCP_STATE_CLOSED (0)
13302#define TCP_STATE_LISTEN (1)
13303#define TCP_STATE_SYN_SENT (2)
13304#define TCP_STATE_SYN_RCVD (3)
13305#define TCP_STATE_WAIT_FOR_ACCEPT (4)
13306#define TCP_STATE_ESTABLISHED (5)
13307#define TCP_STATE_CLOSE_WAIT (6)
13308#define TCP_STATE_LAST_ACK (7)
13309#define TCP_STATE_FIN_WAIT_1 (8)
13310#define TCP_STATE_FIN_WAIT_2 (9)
13311#define TCP_STATE_CLOSING (10)
13312#define TCP_STATE_TIME_WAIT (11)
13327uint8_t TcpGetSocketState(int fd);
13328
13341
13355
13369uint16_t TcpGetTxDataWaiting(int fd);
13370
13385BOOL TcpAllDataAcked(int socket);
13386
13402BOOL WaitForSocketFlush(int fd, uint32_t ticks);
13403
13404
13405
13545typedef void(tcp_notify_handler)(int tcpFd);
13546
13719void RegisterTCPReadNotify(int tcpFd, tcp_notify_handler *notifyHandler);
13720
13928void RegisterTCPWriteNotify(int tcpFd, tcp_notify_handler *notifyHandler);
13932/* associate a void * with tcp */
13933void TCPAssociateExtraData(int tcpFd, void *pData);
13934void *TCPGetExtraData(int tcpFd);
13935
13936
13937
13938#ifdef TCP_THROUGHPUT_INFO
13951 uint64_t TCPGetPayloadBytesSent(int tcpFd);
13952
13965 uint64_t TCPGetPayloadBytesReceived(int tcpFd);
13966
13981 uint64_t TCPGetTotalBytesSent(int tcpFd);
13982
13997 uint64_t TCPGetTotalBytesReceived(int tcpFd);
13998#endif
13999
14000#endif /* #ifndef _NB_TCP_H */
14001
Used to store and manipulate IPv4 addresses in dual stack mode.
Definition nettypes.h:225
static IPADDR4 NullIP()
C++ static function for a null IP address.
Definition nettypes.h:363
Used to hold and manipulate IPv4 and IPv6 addresses in dual stack mode.
Definition ipv6_addr.h:41
static IPADDR6 NullIP()
Static function to return a null IPADDR6 object.
int getsocketerror(int fd)
Get the error status of a socket.
BOOL WaitForSocketFlush(int fd, uint32_t ticks)
Wait for all transmitted data to be acknowledged.
uint16_t GetSocketLocalPort(int fd)
Get the local port number for a socket connection.
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.
Definition tcp.h:8810
int TcpGetSocketInterface(int fd)
Get the network interface number associated with a TCP socket.
int listenvia(const IPADDR &addr, uint16_t port, int ifn, uint8_t maxpend=5)
Create a listening socket on a specific network interface.
Definition tcp.h:7299
int SetSocketUnackBuffers(int fd, uint8_t val)
Configure the maximum number of unacknowledged transmit buffers.
Definition tcp.h:12335
int connect(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout)
Establish a TCP connection to a remote host.
Definition tcp.h:1547
int SetSocketTxBuffers(int fd, int n)
Configure the number of TCP transmit buffers.
IPADDR GetSocketLocalAddr(int fd)
Get the local interface IP address for a socket connection.
Definition tcp.h:9470
uint16_t GetSocketRemotePort(int fd)
Get the remote host port number for a socket connection.
int NoBlockConnect(const IPADDR &ipAddress, uint16_t remotePort)
Initiate a non-blocking TCP connection.
Definition tcp.h:7893
int GetTcpRtxCount(int fd)
Get the number of TCP retransmissions on a socket.
int getsockoption(int fd)
Query current TCP socket options.
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.
Definition tcp.h:2044
uint16_t TcpGetTxDataWaiting(int fd)
Get the number of bytes queued for transmission.
int clrsockoption(int fd, int option)
Disable TCP socket options.
void EnableTcpDebug(uint16_t dbFlags)
Enable TCP debug output with specified flags.
void TcpSendKeepAlive(int fd)
Send a TCP keepalive probe packet.
int SockReadWithTimeout(int fd, char *buf, int nbytes, uint32_t timeout)
Read from a TCP socket with a timeout.
void DumpTcpDebug()
Display current TCP debug information to the console.
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.
Definition tcp.h:3261
int abortsocket(int fd)
Abort a TCP connection immediately.
int NoBlockConnectVia(const IPADDR &ipAddress, uint16_t remotePort, const IPADDR &interfaceIpAddress=IPADDR::NullIP())
Initiate a non-blocking TCP connection via a specific interface.
Definition tcp.h:7919
int accept(int listening_socket, IPADDR *address, uint16_t *port, uint16_t timeout)
Accept an incoming connection on a listening socket.
IPADDR GetSocketRemoteAddr(int fd)
Get the remote host IP address for a socket connection.
Definition tcp.h:9393
int listen(const IPADDR &addr, uint16_t port, uint8_t maxpend=5)
Create a listening socket to accept incoming TCP connections.
Definition tcp.h:6629
BOOL TcpAllDataAcked(int socket)
Check if all transmitted data has been acknowledged.
uint16_t TcpGetRxBufferSpaceUsed(int fd)
Get the number of bytes currently in the receive buffer.
uint32_t TcpGetLastRxTime(int fd)
Get the system tick count when the last packet was received.
uint32_t TcpGetLastRxInterval(int fd)
Get the time elapsed since the last received packet.
int SetSocketRxBuffers(int fd, int n)
Configure the number of TCP receive buffers.
int setsockoption(int fd, int option)
Enable TCP socket options.
uint8_t TcpGetSocketState(int fd)
Get the current TCP state of a socket.
uint16_t TcpGetTxBufferAvailSpace(int fd)
Get the available space in the transmit buffer.
uint8_t SetOutOfOrderBuffers(int fd, uint8_t max)
Configure the maximum number of out-of-order buffers for a TCP socket.
Definition tcp.h:11303
char SocketPeek(int fd)
Peek at the next available byte without removing it from the receive buffer.
void RegisterTCPWriteNotify(int tcpFd, tcp_notify_handler *notifyHandler)
Register a callback for write event notifications.
void RegisterTCPReadNotify(int tcpFd, tcp_notify_handler *notifyHandler)
Register a callback for read event notifications.
void tcp_notify_handler(int tcpFd)
TCP notification callback function type.
Definition tcp.h:13545