on 10bb2fb help sign in
71 lines 2.0 kB history raw
1-- |
2-- Module : Streamly.Network.Socket
3-- Copyright : (c) 2018 Composewell Technologies
4--
5-- License : BSD3
6-- Maintainer : streamly@composewell.com
7-- Stability : experimental
8-- Portability : GHC
9--
10-- A socket is a handle to a protocol endpoint.
11--
12-- This module provides APIs to read and write streams and arrays to and from
13-- network sockets. Sockets may be connected or unconnected. Connected sockets
14-- can only send or recv data to/from the connected endpoint, therefore, APIs
15-- for connected sockets do not need to explicitly specify the remote endpoint.
16-- APIs for unconnected sockets need to explicitly specify the remote endpoint.
17--
18-- Read IO requests to connected stream sockets are performed in chunks of
19-- 32KiB, this is referred to as @defaultChunkSize@ in the documentation. One
20-- IO request may or may not read the full chunk. Unless specified otherwise
21-- in the API, writes are collected into chunks of @defaultChunkSize@ before
22-- they are written to the socket. APIs are provided to control the chunking
23-- and framing behavior.
24--
25-- > import qualified Streamly.Network.Socket as SK
26--
28-- By design, connected socket IO APIs are similar to
29-- "Streamly.Memory.Array" read write APIs. They are almost identical to the
30-- sequential streaming APIs in "Streamly.Internal.FileSystem.File".
31--
32module Streamly.Network.Socket
33 (
34 -- * Socket Specification
35 SockSpec(..)
37 -- * Accept Connections
38 , accept
40 -- * Read
41 , read
42 -- , readUtf8
43 -- , readLines
44 -- , readFrames
45 -- , readByChunks
47 -- -- * Array Read
48 -- , readArrayUpto
49 -- , readArrayOf
51 -- , readArraysUpto
52 , readArraysOf
53 -- , readArrays
55 -- * Write
56 , write
57 -- , writeUtf8
58 -- , writeUtf8ByLines
59 -- , writeByFrames
60 -- , writeInChunksOf
62 -- -- * Array Write
63 -- , writeArray
64 , writeArrays
66 -- reading/writing datagrams
67 )
68where
70import Streamly.Internal.Network.Socket
71import Prelude hiding (read)