3

I want to ask a server, whose IP I know, to send the date and time to a client.

How can I implement this in Java?

jjnguy
  • 136,852
  • 53
  • 295
  • 323
user262842
  • 43
  • 1
  • 5
  • 7
    Some people do not speak English as their first language. – danben Feb 03 '10 at 15:31
  • Can you please clarify your question? I don't understand what it is that you are asking. – Thomas Padron-McCarthy Feb 03 '10 at 15:32
  • I'm confused....what is the question? – SOA Nerd Feb 03 '10 at 15:32
  • 1
    @Vivek Bernard: Oracle actually.. – Roman Feb 03 '10 at 15:35
  • @danben neither do I.I meant it in a lighter sense, no offense. – Vivek Bernard Feb 03 '10 at 15:38
  • 1
    @danben: In either case the problem is not Java. The title should be something in the lines of: "I want to ask a server ... " or "Java IP server how to I want..." But not "A problem about Java" – OscarRyz Feb 03 '10 at 15:39
  • @jinguy: I think you're changing the question. My understanding ( from the original question is: *"How do I query a server, which IP addresses have connected to it and when"* What your "fixing" totally changes that. Probably changing the title would be enough – OscarRyz Feb 03 '10 at 15:49
  • @Oscar Reyes - yes that's fine. It is still inappropriate to ridicule someone for not understanding how to articulate that in a particular language. – danben Feb 03 '10 at 16:04

3 Answers3

3

To start with you'll need to clarify (for yourself as much as anything):

  • What kind of server are you going to ask?
  • How are you going to ask it?
  • What kind of IP are you expecting the server to know about?
  • How would the server know about that IP?
  • What does it look like for an IP to 'respond'?
  • How would the server know that an IP 'responded'?
  • How would the server store the knowledge of the IP responding?

Once you've answered those questions, (and more I'm sure), it'll be easier to answer how to do it in java.

Update

The updated question is much clearer.. nice.

John Weldon
  • 39,849
  • 11
  • 94
  • 127
  • 1
    @John Weldon: The updated question is much clearer, but unless Mr. jinguy can read lightux's mind, I would say that's completely a different question. I think the former ( while not clear ) was about to see what connections have been made to a server. I guess we will never know – OscarRyz Feb 03 '10 at 15:52
  • Actually, I didn't look to see who made the edits. I didn't think that the updated question reflected the original question, but I guess it's up to the OP to clarify.. Thanks @Oscar. – John Weldon Feb 03 '10 at 16:00
2

Your question is not clear so I'll post a number of possible answers.

If the server exists and have a protocol to answer your request

  • A1. Create a program ( probably using Sockets ) to query that server.

If the server exists but doesn't have a protocol to answer your request and YOU own that server and already logs ...which IP has been known to respond the date and time

  • A2. Read those logs in the server ( probably using InputStreamReader ) Create the protocol answer the request ( Socket ) and then go to A1.

If the server exists but doesn't have a protocol to answer your request and you own that server and doesn't logs ...which IP has been known to respond the date and time

  • A3. Forget it

If The server exists but doesn't have a protocol to answer your request and you DON'T own that server.

  • A4. Go to A3

If the server doesn't exists and you can create it.

  • A5 Create the server code and then go to A2

If the server doesn't exist and you cannot create it

  • A6 Go to A3

... And so on.

OscarRyz
  • 196,001
  • 113
  • 385
  • 569