Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

server socket to accept connection from particular ip java

I have a serversocket running on a port say 7761 in my server with ip say 10.2.110.43 now there are many client that run on different servers waiting for connection on port 7761, and write data in ascii format to that port.

I want the serversocket to verify the client-ipadress and then accept connection from client.

Is there a way to do that?

like image 703
Avishek Avatar asked Dec 12 '22 21:12

Avishek


1 Answers

If you don't mind running under a SecurityManager and the list of IP addresses is static, you can accomplish this via the security.policy file. Just grant SocketPermission"accept" to only those IP addresses you want to accept connections from. However doing it in code or the firewall as suggested in another answers is probably preferable.

like image 104
user207421 Avatar answered Dec 29 '22 00:12

user207421