commit adc3364be4cbb48d3bac5116edb4eb8b908f4897 Author: Travis Avey Date: Fri May 15 15:58:07 2026 -0400 source code migrating from gitlab diff --git a/001HelloWorld/main.odin b/001HelloWorld/main.odin new file mode 100644 index 0000000..980ff41 --- /dev/null +++ b/001HelloWorld/main.odin @@ -0,0 +1,62 @@ +package main + +import "core:fmt" +import "core:net" +//import "core:os" + +main :: proc() { + + //args := os.args + //for arg in args { + // fmt.println(arg) + //} + //fmt.printf("hello! %s\n", "world") + server("127.0.0.1", 5500) +} + +server :: proc(ip: string, port: int) { + + addr, ok := net.parse_ip4_address(ip) + if !ok { + fmt.println("could not parse address") + return + } + + endpoint := net.Endpoint { + address = addr, + port = port, + } + + sock, err := net.listen_tcp(endpoint) + if err != nil { + fmt.printf("error creating sock fd: %s\n", err) + return + } + + defer net.close(sock) + + for { + client, src, err := net.accept_tcp(sock) + if err != nil { + fmt.println("error accepting client", err) + continue + } + fmt.println("src: ", src) + handleClient(client) + } +} + +handleClient :: proc(sock: net.TCP_Socket) { + defer net.close(sock) + + + buffer: [2048]u8 + + bytes, err := net.recv_tcp(sock, buffer[:]) + if err != nil { + fmt.println("error recv", err) + return + } + + fmt.printf("%s\n", buffer) +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..95c1a34 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# Odin + + +## For Learning Only + +These little projects are for learning only and you can see the videos: [here](https://www.youtube.com/@aveydotdev) + + +## Collaborate + +Feel free to reach out if something isn't write or there's an update to Odin that could benefit someone learning Odin. Thanks! + +