Click here to Skip to main content
15,897,519 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am working as a free lancer and doing a project on firewall. I have done my task on how to scan a port, now i need to block a port, Are there any methods available from ServerSocket to block a port.

Thankyou.
Posted

To block a port, open it and refuse any connections.
 
Share this answer
 
Comments
Syed Mohammed Khawar 5-Apr-11 2:46am    
Please view my solution.Thanks for adding your solution.
Found the solution, The correct solution is:
Not this:
Socket ServerSok = new Socket(String host,int port);
ServerSok.close();


But this:
ServerSocket socket = new ServerSocket(1066);
while (true) {
    Socket connection = socket.accept();
    connection.close();
}
 
Share this answer
 
v3
Comments
Nagy Vilmos 5-Apr-11 3:09am    
Don't close the socket.
Syed Mohammed Khawar 9-Apr-11 6:00am    
Got it, can I have your codes on this. Because this is really troubling me.
Nagy Vilmos 12-Apr-11 5:58am    
Updated your solution to reflect the solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900