Idris2Doc : Network.Socket.Raw

Network.Socket.Raw

Low-Level C Sockets bindings for Idris. Used by higher-level, cleverer things.
Type-unsafe parts. Use Network.Socket for a safe variant.

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

Reexports

importpublic Network.Socket.Data

Definitions

dataRecvStructPtr : Type
Totality: total
Visibility: public export
Constructor: 
RSPtr : AnyPtr->RecvStructPtr
dataRecvfromStructPtr : Type
Totality: total
Visibility: public export
Constructor: 
RFPtr : AnyPtr->RecvfromStructPtr
dataBufPtr : Type
Totality: total
Visibility: public export
Constructor: 
BPtr : AnyPtr->BufPtr
dataSockaddrPtr : Type
Totality: total
Visibility: public export
Constructor: 
SAPtr : AnyPtr->SockaddrPtr
sock_poke : HasIOio=>BufPtr->Int->Int->io ()
  Put a value in a buffer

Visibility: export
sock_peek : HasIOio=>BufPtr->Int->ioInt
  Take a value from a buffer

Visibility: export
sock_free : HasIOio=>BufPtr->io ()
  Frees a given pointer

Visibility: export
sockaddr_free : HasIOio=>SockaddrPtr->io ()
Visibility: export
sock_alloc : HasIOio=>ByteLength->ioBufPtr
  Allocates an amount of memory given by the ByteLength parameter.

Used to allocate a mutable pointer to be given to the Recv functions.

Visibility: export
getSockPort : HasIOio=>Socket->ioPort
  Retrieves the port the given socket is bound to

Visibility: export
getSockAddr : HasIOio=>SockaddrPtr->ioSocketAddress
  Retrieves a socket address from a sockaddr pointer

Visibility: export
freeRecvStruct : HasIOio=>RecvStructPtr->io ()
Visibility: export
freeRecvfromStruct : HasIOio=>RecvfromStructPtr->io ()
  Utility to extract data.

Visibility: export
sendBuf : HasIOio=>Socket->BufPtr->ByteLength->io (EitherSocketErrorResultCode)
  Sends the data in a given memory location

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

@sock The socket on which to send the message.
@ptr The location containing the data to send.
@len How much of the data to send.

Visibility: export
recvBuf : HasIOio=>Socket->BufPtr->ByteLength->io (EitherSocketErrorResultCode)
  Receive data from a given memory location.

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

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

Visibility: export
sendToBuf : HasIOio=>Socket->SocketAddress->Port->BufPtr->ByteLength->io (EitherSocketErrorResultCode)
  Send a message stored in some buffer.

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.
@ptr A Pointer to the buffer containing the message.
@len The size of the message.

Visibility: export
foreignGetRecvfromPayload : HasIOio=>RecvfromStructPtr->ioString
  Utility function to get the payload of the sent message as a `String`.

Visibility: export
foreignGetRecvfromAddr : HasIOio=>RecvfromStructPtr->ioSocketAddress
  Utility function to return senders socket address.

Visibility: export
foreignGetRecvfromPort : HasIOio=>RecvfromStructPtr->ioPort
  Utility function to return sender's IPV4 port.

Visibility: export
recvFromBuf : HasIOio=>Socket->BufPtr->ByteLength->io (EitherSocketError (UDPAddrInfo, ResultCode))
  Receive a message placed on a 'known' buffer.

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

@sock The channel on which to receive.
@ptr Pointer to the buffer to place the message.
@len Size of the expected message.

Visibility: export