Given the situation you have described, trawling the xinetd logfile is your only option.
If your Java application is talking to the client via its standard input and standard output, there is no way for the application to access the underlying socket. Indeed, I don't think you could do this in any language.
EDIT : actually, you probably could do this in C and C++ because they expose the file descriptors (fds) and have library APIs for doing socket operations using fds.
But it won't work in pure Java. Even if you could drill down to the fd inside the Stream objects associated with System.in
or System.out
, I don't think that the Java class libraries provide an API for turning the fd into a Socket
object. To do socket operations on the fd's 0 and 1 you would need to resort to JNI and native code.
And as the commenter points out, if the real client is behind a proxy, the client IP that you get from the socket will be the IP of the proxy.