Merge branch 'master' of gitea.larke.org:kevin/libcw

This commit is contained in:
kevin 2023-07-25 20:24:39 -04:00
commit 06a8a8ec88
3 changed files with 15 additions and 0 deletions

View File

@ -727,6 +727,7 @@ namespace cw
{ .id=sock::kMultiCastLoopFl, .label="multicast_loop" }, //
{ .id=sock::kListenFl, .label="listen" }, // Use this socket to listen for incoming connections
{ .id=sock::kStreamFl, .label="stream" }, // Connected stream (vs. Datagram)
{ .id=sock::kTcpNoDelayFl, .label="tcp_no_delay" }, // Implements TCP_NODELAY
{ .id=0, .label=nullptr, }
};

View File

@ -8,6 +8,7 @@
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <unistd.h> // close
@ -502,6 +503,7 @@ namespace cw
goto errLabel;
}
errLabel:
return rc;
}
@ -740,6 +742,17 @@ cw::rc_t cw::sock::create( handle_t h,
goto errLabel;
}
}
if( cwIsFlag(flags,kTcpFl) && cwIsFlag(flags,kTcpNoDelayFl) )
{
int nodelay_flag = 1;
if( setsockopt( s->sockH, IPPROTO_TCP, TCP_NODELAY, (void *)&nodelay_flag, sizeof(nodelay_flag)) == cwSOCKET_SYS_ERR )
{
rc = cwLogSysError(kOpFailRC,errno, "Attempt to set the socket NODELAY attribute failed." );
goto errLabel;
}
}
// create the 32 bit local address
if((rc = _initAddr( localAddr, port, &s->localSockAddr )) != kOkRC )

View File

@ -28,6 +28,7 @@ namespace cw
kMultiCastLoopFl = 0x040, //
kListenFl = 0x080, // Use this socket to listen for incoming connections
kStreamFl = 0x100, // Connected stream (not Datagram)
kTcpNoDelayFl = 0x200, // TCP stream option only (Implements TCP_NODELAY)
};
enum