Listener: Listener

This is used for creating the UDP server endpoints. A UDP server endpoint is capable of responding to remote callers. The udp:Listener is responsible for initializing the endpoint using the provided configurations.

Constructor

Initializes the UDP listener based on the privovided configurations.

1 listener Listener|error? udpServer = new (8080);
init (int localPort, *ListenerConfiguration config)
  • localPort int
  • The port number of the remote service

LifeCycle Methods

attach

Binds a service to the udp:Listener.

Methods

'start

Starts the registered service programmatically.

gracefulStop

Stops the service listener gracefully.

immediateStop

Stops the service listener immediately.

detach

Stops consuming messages and detaches the service from the udp:Listener.

attach

function attach(Service s, ()  name) returns error?
Isolated Function

Binds a service to the udp:Listener.

1udp:error? result = udpListener.attach(helloService);

Parameters

  • s Service
  • Type descriptor of the service

  • name () (default ())
  • Name of the service

Return Type

(error?)

() or else a udp:Error upon failure to register the listener

'start

function 'start() returns error?
Isolated Function

Starts the registered service programmatically.

Return Type

(error?)

An error if an error occurred during the listener starting process

gracefulStop

function gracefulStop() returns error?
Isolated Function

Stops the service listener gracefully. Already-accepted requests will be served before connection closure.

Return Type

(error?)

An error if an error occurred during the listener stopping process

immediateStop

function immediateStop() returns error?
Isolated Function

Stops the service listener immediately. It is not implemented yet.

Return Type

(error?)

An error if an error occurred during the listener stop process

detach

function detach(Service s) returns error?
Isolated Function

Stops consuming messages and detaches the service from the udp:Listener.

1udp:error? result = udpListener.detach(helloService);

Parameters

  • s Service
  • Type descriptor of the service

Return Type

(error?)

() or else a udp:Error upon failure to detach the service