This content has been marked as final. Show 10 replies
cssdawla wrote:Every IP package contains the sender IP Address, so that one is trivial.
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.
cssdawla wrote:A discussion of how TCP works is not really in the scope of this forum.
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?
The TCP implementation, aka the OS, handles this.
cssdawla wrote:Of course thats where it gets the address for. Where else?
Yes how does the server know the sender IP Address in a TCP/IP or UDP/Ip or a sevlet?
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.
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()
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.
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?