gftp/listener

The listener module provides a TCP listener for active mode FTP data connections. It wraps Erlang’s gen_tcp:listen/accept to allow the client to accept incoming connections from the FTP server.

Types

A type representing a TCP listen socket.

pub type ListenSocket {
  ListenSocket
}

Constructors

  • ListenSocket

Values

pub fn accept(
  socket: ListenSocket,
  timeout: Int,
) -> Result(mug.Socket, mug.Error)

Accept an incoming connection on the listen socket with a timeout in milliseconds. Returns the accepted socket (compatible with mug.Socket).

pub fn close(socket: ListenSocket) -> Nil

Close the listen socket.

pub fn listen() -> Result(ListenSocket, mug.Error)

Create a TCP listener bound to an ephemeral port on all interfaces. Returns the listen socket on success.

pub fn port(socket: ListenSocket) -> Result(Int, mug.Error)

Get the port number assigned to the listen socket.

Search Document