NetBurner 3.5.6
PDF Version
tcp.h
Go to the documentation of this file.
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
15#ifndef _NB_TCP_H
16#define _NB_TCP_H
17
18#include <predef.h>
19#include <ip.h>
20#include <nettypes.h>
21#include <tcp_private.h>
22
23#ifndef IPV6
24#ifndef IPV4ONLY
25#error Must select an IP version in tcp.h
26#endif
27#endif
28
29#ifdef IPV6
30#ifdef IPV4ONLY
31#error Must select IPV4ONLY or IPV6 but not both
32#endif
33#endif
34
35
36/* TCP socket status and results */
46#define TCP_ERR_NORMAL (0)
47#define TCP_ERR_TIMEOUT (-1)
48#define TCP_ERR_NOCON (-2)
49#define TCP_ERR_CLOSING (-3)
50#define TCP_ERR_NOSUCH_SOCKET (-4)
51#define TCP_ERR_NONE_AVAIL (-5)
52#define TCP_ERR_CON_RESET (-6)
53#define TCP_ERR_CON_ABORT (-7)
76int accept(int listening_socket, IPADDR *address, uint16_t *port, uint16_t timeout);
77
78#ifdef IPV6
79int accept4(int listening_socket, IPADDR4 *address, uint16_t *port, uint16_t timeout);
80#define accept6 accept
81#else
82#define accept4 accept
83#endif
84
104int accept(int listening_socket, IPADDR *address, uint16_t *port, TickTimeout &timeout);
105
119inline int connect(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout)
120{
121 TickTimeout tt(timeout);
122 return CoreConnect(ipAddress, 0, remotePort, tt, IPADDR::NullIP(), -1);
123};
124
143inline int connectvia(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, const IPADDR &localIpAddress)
144{
145 TickTimeout tt(timeout);
146 return CoreConnect(ipAddress, 0, remotePort, tt, localIpAddress, -1);
147};
148
168inline int connectvia(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, int ifnum)
169{
170 TickTimeout tt(timeout);
171 return CoreConnect(ipAddress, 0, remotePort, tt, IPADDR::NullIP(), ifnum);
172};
173
199inline int connectwlocal(const IPADDR &ipAddress,
200 uint16_t localPort,
201 uint16_t remotePort,
202 uint32_t timeout,
203 const IPADDR &localIpAddress = IPADDR::NullIP(),
204 int intf = -1)
205{
206 TickTimeout tt(timeout);
207 return CoreConnect(ipAddress, localPort, remotePort, tt, localIpAddress, intf);
208};
209
210#ifdef IPV6
211inline int connect6(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout)
212{
213 TickTimeout tt(timeout);
214 return CoreConnect(ipAddress, 0, remotePort, tt, IPADDR::NullIP(), -1);
215};
216inline int connectvia6(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, const IPADDR &localIpAddress)
217{
218 TickTimeout tt(timeout);
219 return CoreConnect(ipAddress, 0, remotePort, tt, localIpAddress, -1);
220};
221inline int connectvia6(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout, int ifnum)
222{
223 TickTimeout tt(timeout);
224 return CoreConnect(ipAddress, 0, remotePort, tt, IPADDR::NullIP(), ifnum);
225};
226inline int connectwlocal6(const IPADDR &ipAddress,
227 uint16_t localPort,
228 uint16_t remotePort,
229 uint32_t timeout,
230 const IPADDR &localIpAddress = IPADDR::NullIP(),
231 int ifn = -1)
232{
233 TickTimeout tt(timeout);
234 return CoreConnect(ipAddress, localPort, remotePort, tt, localIpAddress, ifn);
235};
236
237inline int connect4(IPADDR4 ipAddress, uint16_t remotePort, uint32_t timeout)
238{
239 TickTimeout tt(timeout);
240 return CoreConnect4(ipAddress, 0, remotePort, tt, IPADDR4::NullIP(), -1);
241};
242inline int connectvia4(IPADDR4 ipAddress, uint16_t remotePort, uint32_t timeout, IPADDR4 localIpAddress)
243{
244 TickTimeout tt(timeout);
245 return CoreConnect4(ipAddress, 0, remotePort, tt, localIpAddress, -1);
246};
247inline int connectvia4(IPADDR4 ipAddress, uint16_t remotePort, uint32_t timeout, int ifnum)
248{
249 TickTimeout tt(timeout);
250 return CoreConnect4(ipAddress, 0, remotePort, tt, IPADDR4::NullIP(), ifnum);
251};
252inline int connectwlocal4(IPADDR4 ipAddress,
253 uint16_t localPort,
254 uint16_t remotePort,
255 uint32_t timeout,
256 IPADDR4 localIpAddress = IPADDR4::NullIP(),
257 int ifn = -1)
258{
259 TickTimeout tt(timeout);
260 return CoreConnect4(ipAddress, localPort, remotePort, tt, localIpAddress, ifn);
261};
262#else
263#define connect4 connect
264#define connectvia4 connectvia
265#define connectwlocal4 connectwlocal
266#endif
267inline int connect(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout)
268{
269 return CoreConnect(ipAddress, 0, remotePort, timeout, IPADDR::NullIP(), -1);
270};
271
272inline int connectvia(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout, const IPADDR &localIpAddress)
273{
274 return CoreConnect(ipAddress, 0, remotePort, timeout, localIpAddress, -1);
275};
276inline int connectvia(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout, int ifnum)
277{
278 return CoreConnect(ipAddress, 0, remotePort, timeout, IPADDR::NullIP(), ifnum);
279};
280inline int connectwlocal(const IPADDR &ipAddress,
281 uint16_t localPort,
282 uint16_t remotePort,
283 TickTimeout timeout,
284 const IPADDR &localIpAddress = IPADDR::NullIP(),
285 int intf = -1)
286{
287 return CoreConnect(ipAddress, localPort, remotePort, timeout, localIpAddress, intf);
288};
289
290#ifdef IPV6
291inline int connect6(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout)
292{
293 return CoreConnect(ipAddress, 0, remotePort, timeout, IPADDR::NullIP(), -1);
294};
295inline int connectvia6(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout, const IPADDR &localIpAddress)
296{
297 return CoreConnect(ipAddress, 0, remotePort, timeout, localIpAddress, -1);
298};
299inline int connectvia6(const IPADDR &ipAddress, uint16_t remotePort, TickTimeout &timeout, int ifnum)
300{
301 return CoreConnect(ipAddress, 0, remotePort, timeout, IPADDR::NullIP(), ifnum);
302};
303inline int connectwlocal6(const IPADDR &ipAddress,
304 uint16_t localPort,
305 uint16_t remotePort,
306 TickTimeout &timeout,
307 const IPADDR &localIpAddress = IPADDR::NullIP(),
308 int ifn = -1)
309{
310 return CoreConnect(ipAddress, localPort, remotePort, timeout, localIpAddress, ifn);
311};
312
313inline int connect4(IPADDR4 ipAddress, uint16_t remotePort, TickTimeout &timeout)
314{
315 return CoreConnect4(ipAddress, 0, remotePort, timeout, IPADDR4::NullIP(), -1);
316};
317inline int connectvia4(IPADDR4 ipAddress, uint16_t remotePort, TickTimeout &timeout, IPADDR4 localIpAddress)
318{
319 return CoreConnect4(ipAddress, 0, remotePort, timeout, localIpAddress, -1);
320};
321inline int connectvia4(IPADDR4 ipAddress, uint16_t remotePort, TickTimeout &timeout, int ifnum)
322{
323 return CoreConnect4(ipAddress, 0, remotePort, timeout, IPADDR4::NullIP(), ifnum);
324};
325inline int connectwlocal4(IPADDR4 ipAddress,
326 uint16_t localPort,
327 uint16_t remotePort,
328 TickTimeout &timeout,
329 IPADDR4 localIpAddress = IPADDR4::NullIP(),
330 int ifn = -1)
331{
332 return CoreConnect4(ipAddress, localPort, remotePort, timeout, localIpAddress, ifn);
333};
334#endif
356inline int listen(const IPADDR &addr, uint16_t port, uint8_t maxpend = 5)
357{
358 return CoreListen(addr, port, -1, IPADDR::NullIP(), maxpend);
359};
360
379inline int listenvia(const IPADDR &addr, uint16_t port, int ifn, uint8_t maxpend = 5)
380{
381 return CoreListen(addr, port, ifn, IPADDR::NullIP(), maxpend);
382};
383
403inline int listenvia(const IPADDR &addr, uint16_t port, const IPADDR &localIpAddress, uint8_t maxpend = 5)
404{
405 return CoreListen(addr, port, -1, localIpAddress, maxpend);
406};
407
408#ifdef IPV6
409
410inline int listen6(const IPADDR &addr, uint16_t port, uint8_t maxpend = 5)
411{
412 return CoreListen(addr, port, -1, IPADDR::NullIP(), maxpend);
413};
414
415inline int listenvia6(const IPADDR &addr, uint16_t port, int ifn, uint8_t maxpend = 5)
416{
417 return CoreListen(addr, port, ifn, IPADDR::NullIP(), maxpend);
418};
419
420inline int listenvia6(const IPADDR &addr, uint16_t port, const IPADDR &localIpAddress, uint8_t maxpend = 5)
421{
422 return CoreListen(addr, port, -1, localIpAddress, maxpend);
423};
424
425inline int listen4(IPADDR4 addr, uint16_t port, uint8_t maxpend = 5)
426{
427 return CoreListen4(addr, port, -1, IPADDR4::NullIP(), maxpend);
428};
429
430inline int listenvia4(IPADDR4 addr, uint16_t port, int ifn, uint8_t maxpend = 5)
431{
432 return CoreListen(addr, port, ifn, IPADDR4::NullIP(), maxpend);
433};
434
435inline int listenvia4(IPADDR4 addr, uint16_t port, IPADDR4 localIpAddress, uint8_t maxpend = 5)
436{
437 return CoreListen4(addr, port, -1, localIpAddress, maxpend);
438};
439
440#else
441#define listen4 listen
442#define listenvia4 listenvia
443
444#endif
445
465inline int NoBlockConnect(const IPADDR &ipAddress, uint16_t remotePort)
466{
467 return NoBlockCoreConnect(ipAddress, 0, remotePort, IPADDR::NullIP(), -1);
468};
469
494inline int NoBlockConnectVia(const IPADDR &ipAddress, uint16_t remotePort, const IPADDR &interfaceIpAddress = IPADDR::NullIP())
495{
496 return NoBlockCoreConnect(ipAddress, 0, remotePort, interfaceIpAddress, -1);
497};
498
523inline int NoBlockConnectVia(const IPADDR &ipAddress, uint16_t remotePort, int ifnum)
524{
525 return NoBlockCoreConnect(ipAddress, 0, remotePort, IPADDR::NullIP(), ifnum);
526};
527
561inline int NoBlockConnectwlocal(const IPADDR &ipAddress,
562 uint16_t localPort,
563 uint16_t remotePort,
564 IPADDR interfaceIpAddress = IPADDR::NullIP(),
565 int ifn = -1)
566{
567 return NoBlockCoreConnect(ipAddress, localPort, remotePort, interfaceIpAddress, ifn);
568};
569
570#ifdef IPV6
571inline int NoBlockConnect6(const IPADDR &ipAddress, uint16_t remotePort)
572{
573 return NoBlockCoreConnect(ipAddress, 0, remotePort, IPADDR::NullIP(), -1);
574};
575
576inline int NoBlockConnectVia6(const IPADDR &ipAddress, uint16_t remotePort, const IPADDR &interfaceIpAddress = IPADDR::NullIP())
577{
578 return NoBlockCoreConnect(ipAddress, 0, remotePort, interfaceIpAddress, -1);
579};
580
581inline int NoBlockConnectVia6(const IPADDR &ipAddress, uint16_t remotePort, int ifnum)
582{
583 return NoBlockCoreConnect(ipAddress, 0, remotePort, IPADDR::NullIP(), ifnum);
584};
585
586inline int NoBlockConnectwlocal6(const IPADDR &ipAddress, uint16_t localPort, uint16_t remotePort, IPADDR interfaceIpAddress, int ifn = -1)
587{
588 return NoBlockCoreConnect(ipAddress, localPort, remotePort, interfaceIpAddress, ifn);
589};
590
591inline int NoBlockConnect4(const IPADDR4 &ipAddress, uint16_t remotePort, uint32_t timeout)
592{
593 return NoBlockCoreConnect4(ipAddress, 0, remotePort, IPADDR4::NullIP(), -1);
594};
595
596inline int NoBlockConnectVia4(const IPADDR4 &ipAddress, uint16_t remotePort, const IPADDR4 &interfaceIpAddress = IPADDR4::NullIP())
597{
598 return NoBlockCoreConnect4(ipAddress, 0, remotePort, interfaceIpAddress, -1);
599};
600
601inline int NoBlockConnectVia4(const IPADDR4 &ipAddress, uint16_t remotePort, int ifn)
602{
603 return NoBlockCoreConnect4(ipAddress, 0, remotePort, IPADDR4::NullIP(), ifn);
604};
605
606inline int NoBlockConnectwlocal4(const IPADDR4 &ipAddress,
607 uint16_t localPort,
608 uint16_t remotePort,
609 const IPADDR4 &interfaceIpAddress,
610 int ifn = -1)
611{
612 return NoBlockCoreConnect4(ipAddress, localPort, remotePort, interfaceIpAddress, ifn);
613};
614
615#else
616#define NoBlockConnect4 NoBlockConnect
617#define NoBlockConnectVia4 NoBlockConnectVia
618#define NoBlockConnectwlocal4 NoBlockConnectwlocal
619
620#endif
621
622int getsocketerror(int fd);
623
624/* Socket status functions */
625IPADDR4 GetSocketRemoteAddr4(int fd);
626IPADDR4 GetSocketLocalAddr4(int fd);
627
628#ifdef IPV6
629bool bRemoteAddrIsIpV6();
630bool bLocalAddrIsIpV6();
631
632IPADDR GetSocketRemoteAddr6(int fd);
633
634IPADDR GetSocketLocalAddr6(int fd);
635
646{
647 return GetSocketRemoteAddr6(fd);
648};
649
660{
661 return GetSocketLocalAddr6(fd);
662};
663#else
664inline IPADDR4 GetSocketRemoteAddr(int fd)
665{
666 return GetSocketRemoteAddr4(fd);
667};
668inline IPADDR4 GetSocketLocalAddr(int fd)
669{
670 return GetSocketLocalAddr4(fd);
671};
672#endif
673
683uint16_t GetSocketRemotePort(int fd);
684
694uint16_t GetSocketLocalPort(int fd);
695
696/*----- Keepalive functions -----*/
697
718uint32_t TcpGetLastRxTime(int fd);
719
731void TcpSendKeepAlive(int fd);
732
733/*
734 *
735 * Interval in ticks since last received packet
736 *
737 * Parameters:
738 * socket
739 *
740 * Return:
741 * Interval is ticks from now until the last received packet
742 *
743 * Notes:
744 * Will handle one rollover approx. 6 years but not more than one which
745 * given the timeliness of the use of this function should not matter.
746 *
747 */
748
759uint32_t TcpGetLastRxInterval(int fd);
760
768int GetTcpRtxCount(int fd); /* return the number of retransmit counts*/
769
770uint8_t SetOutOfOrderbuffers(int fd, uint8_t max);
771
789inline uint8_t SetOutOfOrderBuffers(int fd, uint8_t max)
790{
791 return SetOutOfOrderbuffers(fd, max);
792}
793
794#if defined MULTIHOME || defined AUTOIP
795
796int connectvia4(IPADDR4 addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, IPADDR4 ipa);
797int NoBlockconnectvia4(IPADDR4 addr, uint16_t localport, uint16_t remoteport, IPADDR4 ipa, int intfnum = -1);
798int connectvia4(IPADDR4 addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, int intfnum);
799
800#ifdef IPV6
801int connectvia6(const IPADDR &addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, const IPADDR &ipa);
802inline int connectvia(const IPADDR &addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, const IPADDR &ipa)
803{
804 return connectvia6(addr, localport, remoteport, timeout, ipa);
805};
806
807int connectvia6(const IPADDR &addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, int intfnum);
808inline int connectvia(const IPADDR &addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, int intfnum)
809{
810 return connectvia6(addr, localport, remoteport, timeout, intfnum);
811};
812
813int NoBlockconnectvia6(IPADDR4 addr, uint16_t localport, uint16_t remoteport, const IPADDR &ipa);
814inline int NoBlockconnectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, const IPADDR &ipa)
815{
816 return NoBlockconnectvia6(addr, localport, remoteport, ipa);
817};
818
819int NoBlockconnectvia6(IPADDR4 addr, uint16_t localport, uint16_t remoteport, int intfnum);
820inline int NoBlockconnectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, int intfnum)
821{
822 return NoBlockconnectvia6(addr, localport, remoteport, intfnum);
823};
824#else
825
826inline int connectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, IPADDR4 ipa)
827{
828 return connectvia4(addr, localport, remoteport, timeout, ipa);
829};
830
831inline int NoBlockconnectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, IPADDR4 ipa)
832{
833 return NoBlockconnectvia4(addr, localport, remoteport, ipa);
834};
835
836inline int connectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, uint32_t timeout, int intfnum)
837{
838 return connectvia4(addr, localport, remoteport, timeout, intfnum);
839};
840
841inline int NoBlockconnectvia(IPADDR4 addr, uint16_t localport, uint16_t remoteport, int intfnum)
842{
843 return NoBlockconnectvia4(addr, localport, remoteport, intfnum);
844};
845#endif
846#endif
847
848/* Get and set the socket options */
849
855#define SO_DEBUG 1
856#define SO_NONAGLE 2
857#define SO_NOPUSH 4
870int setsockoption(int fd, int option);
871
882int clrsockoption(int fd, int option);
883
893int getsockoption(int fd);
894
895int setsocketackbuffers(int fd, uint8_t val);
896
917inline int SetSocketUnackBuffers(int fd, uint8_t val)
918{
919 return setsocketackbuffers(fd, val);
920}
921
942int SetSocketRxBuffers(int fd, int n);
943
959int SetSocketTxBuffers(int fd, int n);
960
968int abortsocket(int fd);
969
990int SockReadWithTimeout(int fd, char *buf, int nbytes, uint32_t timeout);
991
999char SocketPeek(int fd);
1000
1001void DumpTcpDebug();
1002void EnableTcpDebug(uint16_t dbFlags);
1003
1004#ifdef SPEED_TCP
1005typedef void(tcp_data_handler)(int fd, puint8_t data, uint16_t len);
1006void RegisterDataProcessor(int fd, tcp_data_handler *pdh);
1007#endif
1008
1009
1018
1019/* TCP socket states RFC 793 (Do not change) */
1020
1026#define TCP_STATE_CLOSED (0)
1027#define TCP_STATE_LISTEN (1)
1028#define TCP_STATE_SYN_SENT (2)
1029#define TCP_STATE_SYN_RCVD (3)
1030#define TCP_STATE_WAIT_FOR_ACCEPT (4)
1031#define TCP_STATE_ESTABLISHED (5)
1032#define TCP_STATE_CLOSE_WAIT (6)
1033#define TCP_STATE_LAST_ACK (7)
1034#define TCP_STATE_FIN_WAIT_1 (8)
1035#define TCP_STATE_FIN_WAIT_2 (9)
1036#define TCP_STATE_CLOSING (10)
1037#define TCP_STATE_TIME_WAIT (11)
1047uint8_t TcpGetSocketState(int fd);
1048
1060
1071
1082uint16_t TcpGetTxDataWaiting(int fd);
1083
1094BOOL TcpAllDataAcked(int socket);
1095
1108BOOL WaitForSocketFlush(int fd, uint32_t ticks);
1109
1110/*---------------------------------------------------------------------------
1111
1112 Expanded file descriptor callback
1113
1114 Parameters:
1115 tcpFd - Actual connection file descriptor
1116 notifyHandler - Notification callback
1117
1118 Return:
1119 None
1120
1121 Notes:
1122 Data arrival or an connection error state calls this routine.
1123
1124*---------------------------------------------------------------------------*/
1149typedef void(tcp_notify_handler)(int tcpFd);
1150
1161void RegisterTCPReadNotify(int tcpFd, tcp_notify_handler *notifyHandler);
1162
1174void RegisterTCPWriteNotify(int tcpFd, tcp_notify_handler *notifyHandler);
1177/* associate a void * with tcp */
1178void TCPAssociateExtraData(int tcpFd, void *pData);
1179void *TCPGetExtraData(int tcpFd);
1180
1181#ifdef TCP_THROUGHPUT_INFO
1194uint64_t TCPGetPayloadBytesSent(int tcpFd);
1195
1208uint64_t TCPGetPayloadBytesReceived(int tcpFd);
1209
1222uint64_t TCPGetTotalBytesSent(int tcpFd);
1223
1236uint64_t TCPGetTotalBytesReceived(int tcpFd);
1237#endif
1238
1239#endif /* #ifndef _NB_TCP_H */
1240
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.
TickTimeout objects are used to facilitate sequential function calls with timeout parameters that nee...
Definition nbrtos.h:168
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 acknowle...
uint16_t GetSocketLocalPort(int fd)
Returns the local port number associated with the connection.
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...
Definition tcp.h:561
int TcpGetSocketInterface(int fd)
Return the network interface associated with a TCP socket.
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.
Definition tcp.h:379
int SetSocketUnackBuffers(int fd, uint8_t val)
Set the maximum number of outbound TCP buffers in the transmit un-acknowledged list for the specified...
Definition tcp.h:917
int connect(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout)
Make an outgoing TCP connection to a remote host.
Definition tcp.h:119
int SetSocketTxBuffers(int fd, int n)
Set the number of TCP transmit buffers for the specified TCP socket.
IPADDR GetSocketLocalAddr(int fd)
Returns the IP address of the local interface associated with the connection.
Definition tcp.h:659
uint16_t GetSocketRemotePort(int fd)
Returns the port number of the remote host associated with the connection.
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...
Definition tcp.h:465
int GetTcpRtxCount(int fd)
Returns the number of re-transmits that have occurred on the specified connection.
int getsockoption(int fd)
Returns the options for the specified TCP socket.
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.
Definition tcp.h:143
uint16_t TcpGetTxDataWaiting(int fd)
Returns the number of bytes waiting to be sent in a socket's TX Buffer.
int clrsockoption(int fd, int option)
Clear TCP socket options.
void TcpSendKeepAlive(int fd)
Send a TCP keep alive packet to a remote host.
int SockReadWithTimeout(int fd, char *buf, int nbytes, uint32_t timeout)
Attempt to read from a TCP socket until the timeout expires.
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 add...
Definition tcp.h:199
int abortsocket(int fd)
Execute an abort on the specified TCP socket.
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...
Definition tcp.h:494
int accept(int listening_socket, IPADDR *address, uint16_t *port, uint16_t timeout)
Accept an incoming connection from a listening socket.
IPADDR GetSocketRemoteAddr(int fd)
Returns the IP address of the remote host associated with the specified file descriptor.
Definition tcp.h:645
int listen(const IPADDR &addr, uint16_t port, uint8_t maxpend=5)
Listen for incoming connections on the specified network interface IP address.
Definition tcp.h:356
BOOL TcpAllDataAcked(int socket)
Check the data acknowledged state of a socket.
uint16_t TcpGetRxBufferSpaceUsed(int fd)
Returns the number of bytes used in a socket's RX buffer.
uint32_t TcpGetLastRxTime(int fd)
Returns the value of system Time Ticks when the last packet was received. Used for the TCP Keep Alive...
uint32_t TcpGetLastRxInterval(int fd)
Returns the number of system Time Ticks since the last packet was received. This is the difference be...
int SetSocketRxBuffers(int fd, int n)
Set the number of TCP receive buffers for the specified TCP socket.
int setsockoption(int fd, int option)
Set TCP socket options.
uint8_t TcpGetSocketState(int fd)
Return the current state of a TCP socket.
uint16_t TcpGetTxBufferAvailSpace(int fd)
Returns the number of bytes available in a socket's TX buffer.
uint8_t SetOutOfOrderBuffers(int fd, uint8_t max)
Set the maximum number of out-of-order TCP buffers for the specified TCP socket.
Definition tcp.h:789
char SocketPeek(int fd)
Returns the next char that would be read, 0 if no data.
void RegisterTCPWriteNotify(int tcpFd, tcp_notify_handler *notifyHandler)
Register a TCP socket and callback function for write notifications.
void RegisterTCPReadNotify(int tcpFd, tcp_notify_handler *notifyHandler)
Register a TCP socket and callback function for read notifications.
void tcp_notify_handler(int tcpFd)
TCP notification callback type.
Definition tcp.h:1149
NetBurner IP Definitions.
NetBurner IPADDR4 Class. See the IPADDR4 Class page for complete documentation.