10 Replies Latest reply: Feb 11, 2009 10:24 AM by 800025 RSS

    Java Client Server programming

    807588
      Hi,

      i have a question about the client server System. I have implemented in Java a simple client which send the request 5+5 to a web service in an Axis server, which answer with 10.

      I want to know how generally does the server fetch the ip address of the client ? I assume the socket on the server side does the further work.

      Thanks in advance for responding and helping me.

      Kind regards,
      Saber
        • 1. Re: Java Client Server programming
          JoachimSauer
          cssdawla wrote:
          I want to know how generally does the server fetch the ip address of the client ? I assume the socket on the server side does the further work.
          Every IP package contains the sender IP Address, so that one is trivial.
          • 2. Re: Java Client Server programming
            807588
            Huh?

            What do you mean "how does the server fetch the ip address of the client"? Are you asking how to get the client ip address in a Servlet? Or are you asking how does TCP/IP work?
            • 3. Re: Java Client Server programming
              807588
              Hi,

              i know that the sender IP Address in the IP Package is but how does the server fetch this IP Address from the package to answer the right client and not another one?

              Kind regards,
              Saber
              • 4. Re: Java Client Server programming
                807588
                Hi,

                Yes how does the server know the sender IP Address in a TCP/IP or UDP/Ip or a sevlet?

                Kind regards,
                Saber
                • 5. Re: Java Client Server programming
                  807588
                  cssdawla wrote:
                  Hi,

                  i know that the sender IP Address in the IP Package is but how does the server fetch this IP Address from the package to answer the right client and not another one?
                  A discussion of how TCP works is not really in the scope of this forum.

                  The TCP implementation, aka the OS, handles this.
                  • 6. Re: Java Client Server programming
                    JoachimSauer
                    cssdawla wrote:
                    Yes how does the server know the sender IP Address in a TCP/IP or UDP/Ip or a sevlet?
                    Of course thats where it gets the address for. Where else?

                    For TCP it's built into the protocol and handled by the operating system.

                    For UDP that application itself has to send to the correct IP, becaues it's connectionless and doesn't have the concept of a reply.
                    • 7. Re: Java Client Server programming
                      800025
                      I don't know if your server is written in java, but if it is, it will do something like this:

                      1) It creates a ServerSocket

                      2) In a loop it will invoke ServerSocket.accept()

                      3) ServerSocket.accept() returns a Socket for each attempt to connect

                      4) On the Socket, invoke Socket.getInetAddress(), returning an InetAddress

                      5) On the InetAddress invoke getHostAddress()

                      That's all.

                      But it doesn' need the IP address. It can just write data to the OutputStream offered by the Socket. The Socket knows to whom it is connected.

                      Piet
                      • 8. Re: Java Client Server programming
                        807588
                        yes the server is written in java.

                        That means the server can with socket.getInetAddress.getHostAddress send the job response to the right client.

                        "But it doesn' need the IP address. It can just write data to the OutputStream offered by the Socket. The Socket knows to whom it is connected."

                        What is the function of the Sender IP Address by the server in such Kommunication case based on http or https?

                        Kind regards,
                        Saber
                        • 9. Re: Java Client Server programming
                          791266
                          What is the function of the Sender IP Address by the server in such Kommunication case based on http or https?
                          None

                          Kaj
                          • 10. Re: Java Client Server programming
                            800025
                            For secure protocols the javax.net.ssl package provides for a SSLServerSocket and SSLSockets. I never used these, so I can't tell much about them.

                            Piet