• Post Reply Bookmark Topic Watch Topic
  • New Topic

Blocking a port

 
Tom Diamond
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Does anyone know how a Java program can block a port so that no connections can be made to it? (Something like implementing a custom firewall).
Thanx,
Tom.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could just create a ServerSocket on that port and discard (set to null) every Socket object returned by the accept method of the ServerSocket without handling them.
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Tom Diamond
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, that seems to be all right but in my case the port seems to be open all the time, or reserved or something so I get an exception saying that the port is being used (I want to block port 135 on a Win2K machine). Is there something I can do for that?
Tom.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the port is already open, there is not much you can do about that... except kill the process that is using the port and then start your program on that port
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
karl koch
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
port 135 is assigned to dce. infos. i dont know how to stop this and what the results would be.
k
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!