Skip to content

Conversation

@FinleyMcIlwaine
Copy link
Contributor

@FinleyMcIlwaine FinleyMcIlwaine commented Sep 24, 2024

The motivation for this is to enable an interface in network-run similar to the open{Client,Server,TCPServer}SocketWithOptions that allows users to set multiple socket option values of potentially different value types, e.g. NoDelay and Linger. See the corresponding PR in network-run

FinleyMcIlwaine added a commit to FinleyMcIlwaine/network-run that referenced this pull request Sep 24, 2024
The existing interface did not allow one to set both `Linger` and `NoDelay`
socket options. With the `SocketOptionValue` introduced in [this `network`
PR](haskell/network#588), this is now possible.
@kazu-yamamoto kazu-yamamoto self-requested a review September 25, 2024 02:07
Copy link
Collaborator

@kazu-yamamoto kazu-yamamoto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that setSocketOptionValue is an extended version of setSockOpt.
So, the name should be setSockOptValue and SockOptValue.
The export list should be setSockOpt, SockOptValue and setSockOptValue in order.

@FinleyMcIlwaine FinleyMcIlwaine force-pushed the finley/existential-socket-option-values branch from 3893a87 to 2c2a445 Compare September 25, 2024 14:16
@FinleyMcIlwaine
Copy link
Contributor Author

That makes sense to me, I've updated this!

@FinleyMcIlwaine FinleyMcIlwaine force-pushed the finley/existential-socket-option-values branch from 2c2a445 to 39d6b8d Compare September 25, 2024 14:17
FinleyMcIlwaine added a commit to FinleyMcIlwaine/network-run that referenced this pull request Sep 25, 2024
The existing interface did not allow one to set both `Linger` and `NoDelay`
socket options. With the `SocketOptValue` introduced in [this `network`
PR](haskell/network#588), this is now possible.
@kazu-yamamoto kazu-yamamoto self-requested a review September 26, 2024 06:17
(#poke struct linger, l_linger) p linger
#endif

-- | Existential socket option value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that "existential" is too academic to understand for many users.
How about this?
"A data type to hold several different socket option types such as Int and StructLinger".
Please feel free to fix my broken English.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, thanks, I was also a bit worried about that. What you wrote sounds great, I'll update this!

@FinleyMcIlwaine FinleyMcIlwaine force-pushed the finley/existential-socket-option-values branch from 39d6b8d to 85a4b71 Compare September 26, 2024 14:17
@kazu-yamamoto kazu-yamamoto self-requested a review September 27, 2024 00:08
kazu-yamamoto
kazu-yamamoto previously approved these changes Sep 27, 2024
Copy link
Collaborator

@kazu-yamamoto kazu-yamamoto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry for not noticing this yesterday.
Socket should be Sock.
I will merge this PR with this modifications.

@FinleyMcIlwaine
Copy link
Contributor Author

Whoops, sorry about that. Fixed!

See docs for `setSockOptValue`
@FinleyMcIlwaine FinleyMcIlwaine force-pushed the finley/existential-socket-option-values branch from da15ef8 to f0b472e Compare September 27, 2024 00:13
@FinleyMcIlwaine FinleyMcIlwaine changed the title Add SocketOptionValue and setSocketOptionValue Add SockOptValue and setSockOptValue Sep 27, 2024
FinleyMcIlwaine added a commit to FinleyMcIlwaine/network-run that referenced this pull request Sep 27, 2024
The existing interface did not allow one to set both `Linger` and `NoDelay`
socket options. With the `SockOptValue` introduced in [this `network`
PR](haskell/network#588), this is now possible.
kazu-yamamoto added a commit to kazu-yamamoto/network that referenced this pull request Sep 27, 2024
@kazu-yamamoto
Copy link
Collaborator

Merged.
Please check and close this PR if OK.

@FinleyMcIlwaine
Copy link
Contributor Author

Looks good to me, thank you!

@kazu-yamamoto
Copy link
Collaborator

A new version has been released.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jan 30, 2025
## Version 3.2.7.0

* Using nested `bracket` for `gracefulClose`.
  [#591](haskell/network#590)
* Fix memory leak in getaddrinfo and make it async exception safe.
  [#591](haskell/network#591)
* Make call to c_free async exception safe.
  [#592](haskell/network#592)

## Version 3.2.6.0

* fixing the Show instance of IPv4-mapped IPv6 address on little endian machines

## Version 3.2.5.0

* `gracefulClose` based on STM racing and `timeout`.
  [#587](haskell/network#587)

## Version 3.2.4.0

* New API: setSockOptValue.
  [#588](haskell/network#588)

## Version 3.2.3.0

* Making getAddrInfo polymorphic
  [#587](haskell/network#587)

## Version 3.2.2.0

* New API: waitReadSocketSTM, waitAndCancelReadSocketSTM,
  waitWriteSocketSTM, waitAndCancelWriteSocketSTM
  [#586](haskell/network#586)
* Checking the length of ASCII string allowing trailing 0.
  [#585](haskell/network#585)

## Version 3.2.1.0

* Trying to release with the latest autoreconf.
  Packing "network" in the local directory instead of CI.
* Remove includes from .cabal-file
  [#583](haskell/network#583)
* making gracefulClose more graceful
  [#580](haskell/network#580)
* Update config.guess, config.sub to their latest versions
  [#579](haskell/network#579)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants