echoping does not connect or handle the TCP socket, the plugin has to do it.

MAINT_6_0
Stephane Bortzmeyer 17 years ago
parent 4e0eebfeb8
commit baa60a539c

@ -6,11 +6,14 @@ echoping a struct addrinfo. All the DNS stuff, including IDN, is
performed by echoping. You can immediately start using the struct
addrinfo.
But some libraries (typically, the one used by the DBMS) do not work
But some libraries (typically, the one used by the DBMSs) do not work
on struct addrinfo but on strings such as "dbname=test
hostname=foo.bar". Plugins using these libraries will have to use the
raw interface. The host name given as argument is ignored.
[Do note there is *no* interface where the TCP connection and shutdown
are done by echoping. They are always performed by the plugin.]
You indicate to echoping wether you use the raw interface or the
cooked one by returning a port name or NULL from the init() function.

@ -21,6 +21,7 @@ int n;
int sockfd;
FILE *files = NULL;
poptContext whois_poptcon;
echoping_options general_options;
void
whois_usage(const char *msg)
@ -46,6 +47,7 @@ init(const int argc, const char **argv, echoping_options global_options)
""},
POPT_AUTOHELP POPT_TABLEEND
};
general_options = global_options;
if (global_options.udp)
err_quit("UDP is incompatible with this whois plugin");
/* Will probably be catched before because /etc/services have no entry for
@ -88,6 +90,10 @@ execute()
int nr = 0;
char recvline[MAX_LINE + 1];
char complete_request[MAX_REQUEST];
#ifdef HAVE_TCP_INFO
struct tcp_info tcpinfo;
socklen_t socket_length = sizeof(tcpinfo);
#endif
if ((sockfd =
socket(whois_server.ai_family, whois_server.ai_socktype,
whois_server.ai_protocol)) < 0)
@ -106,6 +112,17 @@ execute()
printf("%s", recvline);
if (dump)
printf("\n");
#ifdef HAVE_TCP_INFO
/* Thanks to Perry Lorier <perry@coders.net> for the tip */
if (general_options.verbose) {
if (getsockopt
(sockfd, SOL_TCP, TCP_INFO, &tcpinfo, &socket_length)
!= -1) {
printf("Estimated TCP RTT: %.04f seconds\n",
tcpinfo.tcpi_rtt / 1000000.0);
}
}
#endif
close(sockfd);
return 1;
}

Loading…
Cancel
Save