func main() {
	addr, _ := net.ResolveSCTPAddr("sctp", "localhost:4242")
	conn, _ := net.DialSCTP("sctp", nil, addr)
	defer conn.Close()
	message := []byte("paard")
	conn.WriteToSCTP(message, addr, 55)
}
func echoServer(Address *string, Message *string) {
	addr, _ := net.ResolveSCTPAddr("sctp", *settings.Address)
	conn, err := net.ListenSCTP("sctp", addr)

	if err != nil {
		log.Printf("Error listening: %v", err)
		os.Exit(-1)
	}
	defer conn.Close()

	for {
		msg := make([]byte, 2048)
		log.Printf("Listening on %s", *settings.Address)
		aid, addr, sid, err := conn.ReadFromSCTP(msg)
		if err != nil {
			log.Printf("Error: %v ", err)
			break
		}
		println("********")
		println("Message: " + string(msg))
		println("Stream id: " + strconv.Itoa(int(sid)))
		println("Association id: " + strconv.Itoa(int(aid)))
		println("********")
		conn.WriteTo(msg, addr)
	}

}
Example #3
0
func main() {
	flag.Parse()

	addr, err := net.ResolveSCTPAddr("sctp", *settings.Address)
	if err != nil {
		println(err)
		os.Exit(-1)
	}

	conn, err := net.DialSCTP("sctp", nil, addr)

	if err != nil {
		println("Error listening " + err.Error())
		os.Exit(-1)
	}
	defer conn.Close()

	log.Printf("Dialing to %s", *settings.Address)

	var message = *settings.Message
	bmessage := []byte(message)

	for i := 0; i < *settings.Count; i++ {
		_, err := conn.WriteTo(bmessage, addr)
		if err != nil {
			log.Printf("WriteTo error: %v", err)
			break
		}
	}
}
func main() {
	addr, _ := net.ResolveSCTPAddr("sctp", "localhost:4242")
	conn, err := net.DialSCTP("sctp", nil, addr)
	if err != nil {
		print(err)
		return
	}
	defer conn.Close()
	message := []byte("paarden")
	_, er2 := conn.WriteToSCTP(message, addr, 4)
	if er2 != nil {
		print(er2.Error())
		return
	}
	conn.WriteToSCTP(message, addr, 3)
}
Example #5
0
func main() {
	flag.Parse()

	addr, err := net.ResolveSCTPAddr("sctp", *settings.Address)
	if err != nil {
		println(err)
		os.Exit(-1)
	}

	msg := make([]byte, 2048)
	conn, err := net.DialSCTP("sctp", nil, addr)

	if err != nil {
		println("Error listening " + err.Error())
		os.Exit(-1)
	}
	defer conn.Close()

	log.Printf("Dialing to %s", *settings.Address)

	var message = *settings.Message
	bmessage := []byte(message)

	for {
		//	for i := 0; i < 10; i++ {
		log.Printf("Sending message '%s'", message)
		_, err := conn.WriteTo(bmessage, addr)
		if err != nil {
			log.Printf("WriteTo error: %v", err)
			break
		}
		_, _, err = conn.ReadFrom(msg)
		if err != nil {
			println("ReadFrom error")
			print(err)
			break
		}
		println("Received: " + string(msg))
		time.Sleep(1 * 1e9)
	}
}