diff --git a/src/iperf_api.c b/src/iperf_api.c index 9779e6f..32e9e3b 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -404,6 +404,9 @@ mapped_v4_to_regular_v4(char *str) void iperf_on_connect(struct iperf_test *test) { + time_t now_secs; + const char* rfc1123_fmt = "%a, %d %b %Y %H:%M:%S GMT"; + char now_str[100]; char ipr[INET6_ADDRSTRLEN]; int port; struct sockaddr_storage sa; @@ -412,6 +415,13 @@ iperf_on_connect(struct iperf_test *test) socklen_t len; int opt; + now_secs = time((time_t*) 0); + (void) strftime(now_str, sizeof(now_str), rfc1123_fmt, gmtime(&now_secs)); + if (test->json_output) + cJSON_AddItemToObject(test->json_start, "timestamp", iperf_json_printf("time: %s timesecs: %d", now_str, (int64_t) now_secs)); + else if (test->verbose) + printf("Time: %s\n", now_str); + if (test->role == 'c') { if (test->json_output) cJSON_AddItemToObject(test->json_start, "connecting_to", iperf_json_printf("host: %s port: %d", test->server_hostname, (int64_t) test->server_port));