Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How make ServerSocket only create Socket if connection from OK'd remote address?

 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at the code for ServerSocket, it appears that I can only reject or accept a connection (based on remote address) AFTER the socket has been created (via implAccept() ). But that means a ton of processing and object creation occurs for unallowed addresses. Is there a way to grab the remote address earlier in the process?
 
Joe Ess
Bartender
Posts: 9339
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really don't think that creating a socket instance only to reject it later is going to bring your computer to its knees. If it does, you may want to revisit your server hardware.
If you are looking for a more efficient way to block certain IPs, how about using a firewall? They're designed to do that sort of thing without using a lot of resources and then your software would only have to deal with valid requests. The right tool for the job and all that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic