Idris2Doc : Network.Socket

Network.Socket

Low-Level C Sockets bindings for Idris. Used by higher-level, cleverer things.

Original (C) SimonJF, MIT Licensed, 2014
Modified (C) The Idris Community, 2015, 2016, 2019

Reexports

import public Network.Socket.Data

Definitions

socket : HasIO io => SocketFamily -> SocketType -> ProtocolNumber -> io (Either SocketError Socket)
  Creates a UNIX socket with the given family, socket type and protocol
number. Returns either a socket or an error.

Visibility: export
close : HasIO io => Socket -> io ()
  Close a socket

Visibility: export
bind : HasIO io => Socket -> Maybe SocketAddress -> Port -> io Int
  Binds a socket to the given socket address and port.
Returns 0 on success, an error code otherwise.

Visibility: export
connect : HasIO io => Socket -> SocketAddress -> Port -> io ResultCode
  Connects to a given address and port.
Returns 0 on success, and an error number on error.

Visibility: export
listen : HasIO io => Socket -> io Int
  Listens on a bound socket.

@sock The socket to listen on.

Visibility: export
accept : HasIO io => Socket -> io (Either SocketError (Socket, SocketAddress))
  Accept a connection on the provided socket.

Returns on failure a `SocketError`
Returns on success a pairing of:
+ `Socket` :: The socket representing the connection.
+ `SocketAddress` :: The

@sock The socket used to establish connection.

Visibility: export
send : HasIO io => Socket -> String -> io (Either SocketError ResultCode)
  Send data on the specified socket.

Returns on failure a `SocketError`.
Returns on success the `ResultCode`.

@sock The socket on which to send the message.
@msg The data to send.

Visibility: export
recv : HasIO io => Socket -> ByteLength -> io (Either SocketError (String, ResultCode))
  Receive data on the specified socket.

Returns on failure a `SocketError`
Returns on success a pairing of:
+ `String` :: The payload.
+ `ResultCode` :: The result of the underlying function.

@sock The socket on which to receive the message.
@len How much of the data to receive.

Visibility: export
recvAll : HasIO io => Socket -> io (Either SocketError String)
  Receive all the remaining data on the specified socket.

Returns on failure a `SocketError`
Returns on success the payload `String`

@sock The socket on which to receive the message.

Visibility: export
sendTo : HasIO io => Socket -> SocketAddress -> Port -> String -> io (Either SocketError ByteLength)
  Send a message.

Returns on failure a `SocketError`
Returns on success the `ResultCode`

@sock The socket on which to send the message.
@addr Address of the recipient.
@port The port on which to send the message.
@msg The message to send.

Visibility: export
recvFrom : HasIO io => Socket -> ByteLength -> io (Either SocketError (UDPAddrInfo, (String, ResultCode)))
  Receive a message.

Returns on failure a `SocketError`.
Returns on success a triple of
+ `UDPAddrInfo` :: The address of the sender.
+ `String` :: The payload.
+ `Int` :: Result value from underlying function.

@sock The channel on which to receive.
@len Size of the expected message.

Visibility: export
sendBytes : HasIO m => Socket -> List Bits8 -> m (Either SocketError Int)
  Send data on the specified socket.

Returns on failure a `SocketError`.
Returns on success the number of bytes sent.

@sock The socket on which to send the message.
@bytes The data to send.

Visibility: export
recvBytes : HasIO m => Socket -> ByteLength -> m (Either SocketError (List Bits8))
  Receive data on the specified socket.

Returns on failure a `SocketError`
Returns on success a pairing of:
+ `List Bits8` :: The payload.
+ `ResultCode` :: The result of the underlying function.

@sock The socket on which to receive the message.
@max_size How much of the data to receive at most.

Visibility: export
recvAllBytes : HasIO io => Socket -> io (Either SocketError (List Bits8))
  Receive all the remaining data on the specified socket.

Returns on failure a `SocketError`
Returns on success the payload `List Bits8`

@sock The socket on which to receive the message.

Visibility: export