How to get clients ip in a TCP server?

I have developed a simple TCP chat system, and it works fine. But I need to add a new feature to this Server ie clients validation. I have planned to do by using ip address of clients to validate users. So that I can apply a condition that ""one ip = one user or client"


Do not use IP address as an authentication factor. Use an application layer authentication, many mature implementations exist.

IP address is not secret, not cryptographically strong, can be faked, is not unique (NAT), and is likely to change (renumbering, IPv6 temporary addresses).

IP address can be useful in other ways. Rate limiting, or a risk score of user behavior, or allow listing only certain prefixes. But not for auth itself.