This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Listener - socket : Listener

Represents the socket listener on which the socket listener service is registered and started.

Constructor

__init

(int port, ListenerConfig? config)

  • port int
  • The port number of the remote service

  • config ListenerConfig? ()
  • Configurations related to the socket:Listener

Methods

Stops the socket:Listener gracefully.

Stops the socket:Listener forcefully.

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

LifeCycle Methods

Starts the socket:Listener.

Binds a service to the socket:Listener.

Methods

__gracefulStop

()

returns error?

Stops the socket:Listener gracefully.

 socket:error? result = socketListener.__gracefulStop();
  • Return Type

    (error?)
  • () or else a socket:Error upon failure to stop the listener

__immediateStop

()

returns error?

Stops the socket:Listener forcefully.

 socket:error? result = socketListener.__immediateStop();
  • Return Type

    (error?)
  • () or else a socket:Error upon failure to stop the listener

__detach

(service s)

returns error?

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

 socket:error? result = socketListener.__detach(helloService);

Parameters

  • s service
  • Type descriptor of the service

  • Return Type

    (error?)
  • () or else a socket:Error upon failure to detach the service

LifeCycle Methods

__start

()

returns error?

Starts the socket:Listener.

 socket:error? result = socketListener.__start();
  • Return Type

    (error?)
  • () or else a socket:Error upon failure to start the listener

__attach

(service s, string? name)

returns error?

Binds a service to the socket:Listener.

 socket:error? result = socketListener.__attach(helloService);

Parameters

  • s service
  • Type descriptor of the service

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

  • Return Type

    (error?)
  • () or else a socket:Error upon failure to register the listener