typelead / eta-hackage

A set of patches to make Hackage compatible with the Eta language.
64 stars 31 forks source link

Fix `bindPortTCP` in `streaming-commons` #96

Closed ouromoros closed 6 years ago

ouromoros commented 6 years ago

In the following simple code:

main = do
  s <- bindPortTCP 3000 "*4"
  _ <- accept s
  return ()

An IllegalArgumentException will be thrown because the Channel doesn't support the specified operation, and in this case, accept.

bindPortTCP in streaming-commons library passes NS.Stream as socket type and, as a result, gets a NetworkChannel in return. But only ServerSocketChannel supports accept, so there the problem is.

The solution would be to just change the NS.Stream to NS.ServerSocket NS.Stream. Also, ServerSocketChannel doesn't support TCP_NODELAY, so the options need be changed.