Skip to content

TCPBackend

[Source]

The TCP operations a connection and listener need from the runtime. RuntimeBackend is the production implementation; test code can substitute a fake to drive the connection state machine without real sockets.

trait ref TCPBackend

Constructors

create

[Source]

new ref create()
: TCPBackend ref^

Returns


Public Functions

listen

[Source]

Open a listening socket bound to host:port and subscribe the_actor for accept-readiness events. Returns the ASIO event, or a null event on failure.

fun ref listen(
  the_actor: AsioEventNotify tag,
  host: String val,
  port: String val,
  ip_version: IPVersion = reference)
: AsioEventID

Parameters

Returns


accept

[Source]

Accept one pending connection on the listening socket behind event. Returns the fd (> 0), 0 if none is ready, or -1 on error.

fun ref accept(
  event: AsioEventID)
: I32 val

Parameters

Returns


close

[Source]

Close the socket.

fun ref close(
  fd: U32 val)
: None val

Parameters

Returns


connect

[Source]

Start non-blocking TCP connection attempts to host:port. Returns the number of attempts started (one per resolved address). Zero means every attempt failed immediately.

fun ref connect(
  the_actor: AsioEventNotify tag,
  host: String val,
  port: String val,
  from: String val,
  asio_flags: U32 val,
  ip_version: IPVersion = reference)
: U32 val

Parameters

Returns


keepalive

[Source]

Enable TCP keepalive on fd with an interval of secs seconds.

fun ref keepalive(
  fd: U32 val,
  secs: U32 val)
: None val

Parameters

Returns


peername

[Source]

Fill ip with the remote address of fd. Returns true on success.

fun ref peername(
  fd: U32 val,
  ip: NetAddress tag)
: Bool val

Parameters

Returns


receive

[Source]

Receive up to size bytes into buffer. The call is synchronous and non-blocking: SocketResultRetry means no data was available, SocketResultError means an unrecoverable error or peer close.

fun ref receive(
  event: AsioEventID,
  buffer: Pointer[U8 val] tag,
  size: USize val)
: (SocketResult , USize val)

Parameters

Returns


shutdown

[Source]

Shut down the write side of fd.

fun ref shutdown(
  fd: U32 val)
: None val

Parameters

Returns


sockname

[Source]

Fill ip with the local address of fd. Returns true on success.

fun ref sockname(
  fd: U32 val,
  ip: NetAddress tag)
: Bool val

Parameters

Returns


sendv

[Source]

Send count buffers from data starting at index from. Returns the tri-state socket result plus the number of bytes sent on SocketResultOk. The call is synchronous and non-blocking.

fun ref sendv(
  event: AsioEventID,
  data: Array[ByteSeq] box,
  from: USize val,
  count: USize val,
  first_buffer_byte_offset: USize val = 0)
: (SocketResult , USize val) ?

Parameters

Returns


writev_max

[Source]

Maximum number of buffers a single sendv call may carry.

fun ref writev_max()
: I32 val

Returns