mysql-haskell-1.1.5: pure haskell MySQL driver
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.IO.Streams.TCP

Contents

Description

This module provides convenience functions for interfacing raw tcp.

Please use bracket or its friends to ensure exception safety.

This module is intended to be imported qualified, e.g.:

import           Data.Connection
import qualified System.IO.Streams.TCP as TCP
Synopsis

Documentation

type TCPConnection = Connection (Socket, SockAddr) Source #

Type alias for tcp connection.

Normally you shouldn't use Socket in connExtraInfo directly, this field is intend for used with setSocketOption if you need to.

client

connect Source #

Arguments

:: HostName

hostname to connect to

-> PortNumber

port number to connect to

-> IO TCPConnection 

Connect to server using defaultChunkSize.

connectSocket Source #

Arguments

:: HostName

hostname to connect to

-> PortNumber

port number to connect to

-> IO (Socket, SockAddr) 

Initiating an raw TCP connection to the given (HostName, PortNumber) combination.

It use getAddrInfo to resolve host/service name with AI_ADDRCONFIG, AI_NUMERICSERV hint set, so it should be able to resolve both numeric IPv4/IPv6 hostname and domain name.

TCP_NODELAY are enabled by default. you can use setSocketOption to adjust.

socketToConnection Source #

Arguments

:: Int

receive buffer size

-> (Socket, SockAddr)

socket address pair

-> IO TCPConnection 

Make a Connection from a Socket with given buffer size.

defaultChunkSize :: Int Source #

The chunk size used for I/O, less the memory management overhead.

Currently set to 32k.

server

bindAndListen Source #

Arguments

:: Int

connection limit

-> PortNumber

port number

-> IO Socket 

Bind and listen on port with a limit on connection count.

This function will set SO_REUSEADDR, TCP_NODELAY before binding.

bindAndListenWith Source #

Arguments

:: (Socket -> IO ())

set socket options before binding

-> Int

connection limit

-> PortNumber

port number

-> IO Socket 

Bind and listen on port with a limit on connection count.

Note: The following socket options are inherited by a connected TCP socket from the listening socket:

SO_DEBUG
SO_DONTROUTE
SO_KEEPALIVE
SO_LINGER
SO_OOBINLINE
SO_RCVBUF
SO_RCVLOWAT
SO_SNDBUF
SO_SNDLOWAT
TCP_MAXSEG
TCP_NODELAY

accept :: Socket -> IO TCPConnection Source #

Accept a connection with defaultChunkSize.

acceptWith Source #

Arguments

:: ((Socket, SockAddr) -> IO TCPConnection)

set socket options, adjust receive buffer, etc.

-> Socket 
-> IO TCPConnection 

Accept a connection with user customization.