how to stop socket with linux command?

Solution 1:

Try this. Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

sudo netstat -ap | grep :<port_number>

Also you can try this to close the socket connection

tcpkill -i eth0 host xxx.xxx.xxx.xxx and port yyyy

Replace X with the IP address, and Y with the port number.

also take a look at tcpkill and cutter command