This is open sources Golang network libraries and applications
Teonet v5 is pure Golang implementation of Trudp and Teonet libraries and Teonet applications.
Teonet is designed to create client-server systems and build networks for server applications operating within a microservice architecture. To do this, Teonet creates a network / cloud transport between its members. This transport uses UDP for communication between network peers. UDP packets are encrypted with unique keys. Teonet uses its own UDP-based protocol called Teonet Reliable UDP (TRU) for real-time communication, which allows low latency messages to be sent and protocol reliability features.
It may be done any number of Teonet networks. Each Teonet network has it's own monitor. The messages from one network can be send to another network if you know it unique address.
To learn how to start building software with Teonet use the >> Simple message mode example.
1package main
2
3import (
4 "fmt"
5 "time"
6
7 "github.com/teonet-go/teonet"
8)
9
10const (
11 appName = "Teonet echo client sample application"
12 appShort = "teoechocli"
13 appVersion = "0.0.1"
14 echoServer = "dBTgSEHoZ3XXsOqjSkOTINMARqGxHaXIDxl"
15 sendDelay = 3000
16)
17
18func main() {
19
20 // Teonet application logo
21 teonet.Logo(appName, appVersion)
22
23 // Start Teonet client
24 teo, err := teonet.New(appShort)
25 if err != nil {
26 panic("can't init Teonet, error: " + err.Error())
27 }
28
29 // Connect to Teonet
30 err = teo.Connect()
31 if err != nil {
32 teo.Log().Debug.Println("can't connect to Teonet, error:", err)
33 // time.Sleep(1 * time.Second)
34 // goto connect
35 panic("can't connect to Teonet, error: " + err.Error())
36 }
37
38 // Connect to echo server
39 err = teo.ConnectTo(echoServer,
40
41 // Get messages from echo server
42 func(c *teonet.Channel, p *teonet.Packet, e *teonet.Event) (proc bool) {
43
44 // Skip not Data Events
45 if e.Event != teonet.EventData {
46 return
47 }
48
49 // Print received message
50 fmt.Printf("got from %s, \"%s\", len: %d, id: %d, tt: %6.3fms\n\n",
51 c, p.Data(), len(p.Data()), p.ID(),
52 float64(c.Triptime().Microseconds())/1000.0,
53 )
54 proc = true
55
56 return
57 },
58 )
59 if err != nil {
60 panic("can't connect to server, error: " + err.Error())
61 }
62
63 // Send messages to echo server
64 for {
65 data := []byte("Hello world!")
66 fmt.Printf("send to %s, \"%s\", len: %d\n", echoServer, data, len(data))
67 _, err = teo.SendTo(echoServer, []byte("Hello world!"))
68 if err != nil {
69 fmt.Println(err)
70 }
71 time.Sleep(time.Duration(sendDelay) * time.Millisecond)
72 }
73}
You can find more descriptions and examples on our Github. See alse the Quick Star page.