network-3.1.2.7: Low-level networking interface
Copyright (c) Bryan O'Sullivan 2009
License BSD-style
Maintainer bos@serpentine.com
Stability experimental
Portability POSIX, GHC
Safe Haskell None
Language Haskell2010

Network.Socket.ByteString.Lazy

Description

This module provides access to the BSD socket interface. For detailed documentation, consult your favorite POSIX socket reference. All functions communicate failures by converting the error number to an IOError .

This module is made to be imported with Network.Socket like so:

import Network.Socket
import Network.Socket.ByteString.Lazy
import Prelude hiding (getContents)
Synopsis

Send data to a socket

send Source #

Arguments

:: Socket

Connected socket

-> ByteString

Data to send

-> IO Int64

Number of bytes sent

sendAll Source #

Arguments

:: Socket

Connected socket

-> ByteString

Data to send

-> IO ()

Receive data from a socket

getContents Source #

Arguments

:: Socket

Connected socket

-> IO ByteString

Data received

Receive data from the socket. The socket must be in a connected state. Data is received on demand, in chunks; each chunk will be sized to reflect the amount of data received by individual recv calls.

All remaining data from the socket is consumed. When there is no more data to be received, the receiving side of the socket is shut down. If there is an error and an exception is thrown, the socket is not shut down.

recv Source #

Arguments

:: Socket

Connected socket

-> Int64

Maximum number of bytes to receive

-> IO ByteString

Data received

Receive data from the socket. The socket must be in a connected state. This function may return fewer bytes than specified. If the received data is longer than the specified length, it may be discarded depending on the type of socket. This function may block until a message arrives.

If there is no more data to be received, returns an empty ByteString .