Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use external TCP stack #24

Merged
merged 15 commits into from
Dec 8, 2023
Merged

Use external TCP stack #24

merged 15 commits into from
Dec 8, 2023

Conversation

soypat
Copy link
Owner

@soypat soypat commented Nov 23, 2023

Switching from developing #20 as an internal TCP stack to an externally imported TCP stack.

The External TCP stack is https://github.com/soypat/seqs

@soypat soypat mentioned this pull request Nov 23, 2023
@soypat
Copy link
Owner Author

soypat commented Dec 8, 2023

@scottfeldman Alright gonna go ahead and merge this since it's quite a noisy handful. Not much has changed, just moved files around mostly.

The DHCP and TCP examples are working on my end. To test I'm using the following program. You'll need ot modify the IP below to match the one assigned by DHCP.

# To flash program. This will also attach yourself to the USB output.
$ tinygo flash -target=pico -opt=1 -stack-size=8kb -size=short -monitor  ./examples/tcpserver/
// Modify IP below to match the one assigned by DHCP!
package main

import (
	"fmt"
	"net"
	"net/netip"
	"time"
)

func main() {
	const server = "192.168.1.120:1234" // Edit this to match your DHCP
	raddr := netip.MustParseAddrPort(server)
	conn, err := net.DialTCP("tcp", nil, net.TCPAddrFromAddrPort(raddr))
	if err != nil {
		panic(err)
	}
	// wait a second for SYN/ACK stuff.
	time.Sleep(time.Second)
	dd := make([]byte, 1024)
	go func() {
		for {
			time.Sleep(time.Second)
			n, err := conn.Read(dd)
			if err != nil {
				fmt.Println("rerr", err.Error())
			}
			if n > 0 {
				fmt.Printf("read %q\n", string(dd[:n]))
			}
		}
	}()
	for {
		_, err = conn.Write([]byte("hello"))
		if err != nil {
			fmt.Println("werr", err.Error())
		}
		time.Sleep(time.Second)
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant