Fixed bug with wrong line numbers in error messages. Some examples refactoring and bug fixes. (0.39.15)
This commit is contained in:
parent
53ccdbda10
commit
3d3c11496f
23 changed files with 265 additions and 114 deletions
32
examples/blocking/tcp_echo_server_class.fun
Executable file
32
examples/blocking/tcp_echo_server_class.fun
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2025-10-13
|
||||
*/
|
||||
|
||||
// Echo server using the stdlib TcpServer class.
|
||||
// Make sure FUN_LIB_DIR points to the ./lib directory containing io/socket.fun.
|
||||
// Example:
|
||||
// FUN_LIB_DIR="$(pwd)/lib" ./build/fun ./examples/tcp_echo_server_class.fun
|
||||
|
||||
include <io/socket.fun>
|
||||
|
||||
print("Starting echo server at localhost:12345")
|
||||
|
||||
server = TcpServer(12345, 16)
|
||||
|
||||
if (server.listen() <= 0)
|
||||
print("Listen failed!")
|
||||
exit(1)
|
||||
else
|
||||
print("Echo server (class) listening on port 12345")
|
||||
|
||||
// Serve clients forever, echoing back what they send.
|
||||
server.serve_forever(4096)
|
||||
Loading…
Add table
Add a link
Reference in a new issue