Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class Socket sock where
- class (DataSocket (Client sock), Socket sock) => ListenSocket sock where
- class Socket sock => DataSocket sock where
- data SocketConfig = SocketConfig {
- scRecvBufferSize :: !Int
- defaultSocketConfig :: SocketConfig
- type SockPort = Word16
- data UdpSocket addr
- newUdpSocket :: (HasNetworkStack ns, Network addr) => ns -> SocketConfig -> Maybe Device -> addr -> Maybe SockPort -> IO (UdpSocket addr)
- sendto :: Network addr => UdpSocket addr -> addr -> SockPort -> ByteString -> IO ()
- recvfrom :: Network addr => UdpSocket addr -> IO (Device, addr, SockPort, ByteString)
- recvfrom' :: Network addr => UdpSocket addr -> IO (Device, addr, SockPort, addr, ByteString)
- data TcpSocket addr
- data TcpListenSocket addr
- tcpRemoteAddr :: NetworkAddr addr => Getting r (TcpSocket addr) addr
- tcpRemotePort :: Getting r (TcpSocket addr) SockPort
- tcpLocalAddr :: NetworkAddr addr => Getting r (TcpSocket addr) addr
- tcpLocalPort :: Getting r (TcpSocket addr) SockPort
- data ConnectionException
- data ListenException
- data RoutingException
Abstract Sockets
class (DataSocket (Client sock), Socket sock) => ListenSocket sock where Source #
class Socket sock => DataSocket sock where Source #
sConnect :: (HasNetworkStack ns, Network addr) => ns -> SocketConfig -> Maybe Device -> addr -> Maybe SockPort -> addr -> SockPort -> IO (sock addr) Source #
Connect this socket to one on a remote machine.
sCanWrite :: Network addr => sock addr -> IO Bool Source #
Returns True iff there is currently space in the buffer to accept a write. Note, this is probably a bad thing to count on in a concurrent system ...
sWrite :: Network addr => sock addr -> ByteString -> IO Int Source #
Send a chunk of data on a socket.
sCanRead :: Network addr => sock addr -> IO Bool Source #
Returns True iff there is data in the buffer that can be read. Note, this is probably a bad thing to count on in a concurrent system ...
sRead :: Network addr => sock addr -> Int -> IO ByteString Source #
Read a chunk of data from a socket. Reading an empty result indicates that the socket has closed.
sTryRead :: Network addr => sock addr -> Int -> IO (Maybe ByteString) Source #
Non-blocking read from a socket. Reading an empty result means that the
socket has closed, while reading a Nothing
result indicates that there
was no data available.
data SocketConfig Source #
SocketConfig | |
|
UDP Sockets
newUdpSocket :: (HasNetworkStack ns, Network addr) => ns -> SocketConfig -> Maybe Device -> addr -> Maybe SockPort -> IO (UdpSocket addr) Source #
sendto :: Network addr => UdpSocket addr -> addr -> SockPort -> ByteString -> IO () Source #
Send to a specific end host.
recvfrom :: Network addr => UdpSocket addr -> IO (Device, addr, SockPort, ByteString) Source #
Receive, with information about who sent this datagram.
recvfrom' :: Network addr => UdpSocket addr -> IO (Device, addr, SockPort, addr, ByteString) Source #
TCP Sockets
data TcpListenSocket addr Source #
tcpRemoteAddr :: NetworkAddr addr => Getting r (TcpSocket addr) addr Source #
The remote address of this socket.
tcpLocalAddr :: NetworkAddr addr => Getting r (TcpSocket addr) addr Source #
The source address of this socket.
Exceptions
data ConnectionException Source #