Pudu programming language
Menu
API reference

Std.Net.listen

1 declaration

fn

listen: Str -> Int -> Result[Std.Net.Listener, Std.Net.NetError]

This is a callable function.

What it does

Wait for connections on a port.

A port of zero asks the machine to choose one, which portOf then answers.

That is how a program starts a listener without picking a number something

else may already hold, and it is what a test wants.

The address is made reusable before it is bound, so a program restarted

straight after stopping can bind the port it just had rather than waiting

out the connections that may still be in flight.

Read the signature

  • The text after the name is the type checked by Pudu.
  • Read arrows from left to right: inputs come first, and the final type is returned.
  • Names inside [ ] are type arguments, such as the item type held by a collection.
  • Result makes success and recoverable failure part of the function's type.

Back to Std.NetSearch related declarations