Beispiel #1
0
func startClient(network string, host string, portno int, isStream bool) (socket *udtgo.Socket, err error) {

	socket, err = udtgo.CreateSocket(network, isStream)
	if err != nil {
		return nil, fmt.Errorf("Unable to create socket :%s", err)
	}

	n, err := udtgo.Connect(socket, host, portno)

	if err != nil {
		return nil, fmt.Errorf("Unable to connect to the socket :%s %d", err, n)
	}

	return
}
Beispiel #2
0
func startServer(portno int, network string, isStream bool) (socket *udtgo.Socket, err error) {

	socket, err = udtgo.CreateSocket(network, isStream)
	if err != nil {
		return nil, fmt.Errorf("Unable to create socket :%s", err)
	}
	n, err := udtgo.Bind(socket, portno)
	if err != nil {
		return nil, fmt.Errorf("Unable to bind socket :%d", n)
	}
	n, err = udtgo.Listen(socket, 4)
	if err != nil {
		return nil, fmt.Errorf("Unable to listen socket :%d", n)
	}

	return
}