Skip to content

Commit

Permalink
Merge pull request #600 from christopherm99/mac-timeout-2
Browse files Browse the repository at this point in the history
Revert #599 and add new SocketOption `KeepInit`
  • Loading branch information
kazu-yamamoto authored Jan 28, 2025
2 parents 412cb41 + 1b01106 commit c00be44
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions Network/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ module Network.Socket (
SendBuffer,
RecvBuffer,
KeepAlive,
KeepInit,
OOBInline,
TimeToLive,
MaxSegment,
Expand Down
16 changes: 12 additions & 4 deletions Network/Socket/Options.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module Network.Socket.Options (
SocketOption(SockOpt
,UnsupportedSocketOption
,AcceptConn,Debug,ReuseAddr,SoDomain,Type,SoProtocol,SoError
,DontRoute,Broadcast,SendBuffer,RecvBuffer,KeepAlive,OOBInline
,TimeToLive,MaxSegment,NoDelay,Cork,Linger,ReusePort
,DontRoute,Broadcast,SendBuffer,RecvBuffer,KeepAlive,KeepInit
,OOBInline,TimeToLive,MaxSegment,NoDelay,Cork,Linger,ReusePort
,RecvLowWater,SendLowWater,RecvTimeOut,SendTimeOut
,UseLoopBack,UserTimeout,IPv6Only
,RecvIPv4TTL,RecvIPv4TOS,RecvIPv4PktInfo
Expand Down Expand Up @@ -77,6 +77,7 @@ socketOptionBijection =
, (SendBuffer, "SendBuffer")
, (RecvBuffer, "RecvBuffer")
, (KeepAlive, "KeepAlive")
, (KeepInit, "KeepInit")
, (OOBInline, "OOBInline")
, (Linger, "Linger")
, (ReusePort, "ReusePort")
Expand Down Expand Up @@ -220,6 +221,15 @@ pattern KeepAlive = SockOpt (#const SOL_SOCKET) (#const SO_KEEPALIVE)
#else
pattern KeepAlive = SockOpt (-1) (-1)
#endif
-- | TCP_KEEPINIT
pattern KeepInit :: SocketOption
#ifdef TCP_KEEPINIT
pattern KeepInit = SockOpt (#const IPPROTO_TCP) (#const TCP_KEEPINIT)
#elif defined(TCP_CONNECTIONTIMEOUT)
pattern KeepInit = SockOpt (#const IPPROTO_TCP) (#const TCP_CONNECTIONTIMEOUT)
#else
pattern KeepInit = SockOpt (-1) (-1)
#endif
-- | SO_OOBINLINE
pattern OOBInline :: SocketOption
#ifdef SO_OOBINLINE
Expand Down Expand Up @@ -299,8 +309,6 @@ pattern NoDelay = SockOpt (-1) (-1)
pattern UserTimeout :: SocketOption
#ifdef TCP_USER_TIMEOUT
pattern UserTimeout = SockOpt (#const IPPROTO_TCP) (#const TCP_USER_TIMEOUT)
#elif defined(TCP_CONNECTIONTIMEOUT)
pattern UserTimeout = SockOpt (#const IPPROTO_TCP) (#const TCP_CONNECTIONTIMEOUT)
#else
pattern UserTimeout = SockOpt (-1) (-1)
#endif
Expand Down
4 changes: 2 additions & 2 deletions tests/Network/SocketSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ sockoptPatterns :: [SocketOption]
sockoptPatterns = nub
[UnsupportedSocketOption
,Debug,ReuseAddr,SoDomain,Type,SoProtocol,SoError,DontRoute
,Broadcast,SendBuffer,RecvBuffer,KeepAlive,OOBInline,TimeToLive
,MaxSegment,NoDelay,Cork,Linger,ReusePort
,Broadcast,SendBuffer,RecvBuffer,KeepAlive,KeepInit,OOBInline
,TimeToLive,MaxSegment,NoDelay,Cork,Linger,ReusePort
,RecvLowWater,SendLowWater,RecvTimeOut,SendTimeOut
,UseLoopBack,UserTimeout,IPv6Only
,RecvIPv4TTL,RecvIPv4TOS,RecvIPv4PktInfo
Expand Down

0 comments on commit c00be44

Please sign in to comment.