- /* initialize address */
- memset((void *) &serv_add, 0, sizeof(serv_add)); /* clear server address */
- serv_add.sin_family = AF_INET; /* address type is INET */
- serv_add.sin_port = htons(7); /* echo port is 7 */
- /* build address using inet_pton */
- if ( (inet_pton(AF_INET, argv[optind], &serv_add.sin_addr)) <= 0) {
- perror("Address creation error");
- return 1;
- }
- /* extablish connection */
- if (connect(sock, (struct sockaddr *)&serv_add, sizeof(serv_add)) < 0) {
- perror("Connection error");
- return 1;
+ /* print some info about the socket, used to test some TCP_* options */
+ if (verbosity) {
+ len = sizeof(buffer);
+ if (getsockopt(sock, SOL_TCP, TCP_CONGESTION, buffer, &len) < 0) {
+ perror("Cannot read congestion algorithm");
+ } else {
+ buffer[len]=0;
+ printf("Congestion algorithm %s\n", buffer);
+ }