func checkArguments() {

	incorrect := false
	// need 4 arguments device tcp port header
	if len(os.Args) != 5 {
		fmt.Println("not enough parameters, 4 are needed")
		showUsage()
	}
	// check if arguments are correct
	ip = os.Args[1]
	if ip == "" {
		fmt.Println("ip is empty")
		incorrect = true
	}

	port = os.Args[2]
	if _, err := strconv.Atoi(port); err != nil {
		fmt.Println(port, "is not a correct TCP port")
		incorrect = true
	}

	header = os.Args[3]
	if header == "" {
		fmt.Println("header is empty")
		incorrect = true
	}

	command = os.Args[4]
	if command == "" {
		fmt.Println("command is empty")
		incorrect = true
	}

	if incorrect {
		showUsage()
	}

	address = strings.Join([]string{ip, ":", port}, "")

}
// check if all arguments are not empty and correct
check if all arguments are not empty and correct
// check if all arguments are not empty and correct
func checkArguments() {
	incorrect := false
	if len(os.Args) != 5 {
		fmt.Println("not enough parameters, 4 are needed")
		showUsage()
	}
	ip = os.Args[1]
	if ip == "" {
		fmt.Println("ip is empty")
		incorrect = true
	}
	port = os.Args[2]
	if _, err := strconv.Atoi(port); err != nil {
		fmt.Println(port, "is not a correct TCP port")
		incorrect = true
	}
	header = os.Args[3]
	if header == "" {
		fmt.Println("header is empty")
		incorrect = true
	}
	command = os.Args[4]
	if command == "" {
		fmt.Println("command is empty")
		incorrect = true
	}
	if incorrect {
		showUsage()
	}
	address = strings.Join([]string{ip, ":", port}, "")
}
func checkArguments ( ) { incorrect := false if len ( os . Args ) != 5 { fmt . Println ( " " ) showUsage ( ) } ip = os . Args [ 1 ] if ip == " " { fmt . Println ( " " ) incorrect = true } port = os . Args [ 2 ] if _ , err := strconv . Atoi ( port ) ; err != nil { fmt . Println ( port , " " ) incorrect = true } header = os . Args [ 3 ] if header == " " { fmt . Println ( " " ) incorrect = true } command = os . Args [ 4 ] if command == " " { fmt . Println ( " " ) incorrect = true } if incorrect { showUsage ( ) } address = strings . Join ( [ ] string { ip , " " , port } , " " ) }
check if all arguments are not empty and correct
check if all arguments are not empty and correct
// need 4 arguments device tcp port header // check if arguments are correct