| Copyright | (c) Dong Han 2018 |
|---|---|
| License | BSD |
| Maintainer | winterland1989@gmail.com |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Z.IO.Network.TCP
Contents
Description
This module provides an API for creating TCP servers and clients.
Synopsis
- data TCPClientConfig = TCPClientConfig {}
- defaultTCPClientConfig :: TCPClientConfig
- initTCPClient :: HasCallStack => TCPClientConfig -> Resource UVStream
- getTCPSockName :: HasCallStack => UVStream -> IO SocketAddr
- data TCPServerConfig = TCPServerConfig {}
- defaultTCPServerConfig :: TCPServerConfig
- startTCPServer :: HasCallStack => TCPServerConfig -> IO ()
- getTCPPeerName :: HasCallStack => UVStream -> IO SocketAddr
TCP Client
data TCPClientConfig Source #
A TCP client configuration
Constructors
| TCPClientConfig | |
Fields
| |
defaultTCPClientConfig :: TCPClientConfig Source #
Default config, connect to localhost:8888.
initTCPClient :: HasCallStack => TCPClientConfig -> Resource UVStream Source #
init a TCP client Resource, which open a new connect when used.
getTCPSockName :: HasCallStack => UVStream -> IO SocketAddr Source #
Get the current address to which the handle is bound.
TCP Server
data TCPServerConfig Source #
A TCP server configuration
Constructors
| TCPServerConfig | |
Fields
| |
defaultTCPServerConfig :: TCPServerConfig Source #
A default hello world server on localhost:8888
Test it with main = startTCPServer defaultTCPServerConfig, now try nc -v 127.0.0.1 8888
startTCPServer :: HasCallStack => TCPServerConfig -> IO () Source #
Start a server
Fork new worker thread upon a new connection.
getTCPPeerName :: HasCallStack => UVStream -> IO SocketAddr Source #
Get the address of the peer connected to the handle.