lsof print numeric ports

Run lsof -P. And make sure the P goes before the i, if you combine the option with -i: lsof -Pi According to man lsof, -P inhibits the conversion of port numbers to port names for network files. Inhibiting the conversion may make lsof run a little faster. It is also useful when port name … Read more

What are examples of TCP and UDP in real life?

UDP: Anything where you don’t care too much if you get all data always Tunneling/VPN (lost packets are ok – the tunneled protocol takes care of it) Media streaming (lost frames are ok) Games that don’t care if you get every update Local broadcast mechanisms (same application running on different machines “discovering” each other) TCP: … Read more

Instantly detect client disconnection from server socket

Since there are no events available to signal when the socket is disconnected, you will have to poll it at a frequency that is acceptable to you. Using this extension method, you can have a reliable method to detect if a socket is disconnected. static class SocketExtensions { public static bool IsConnected(this Socket socket) { … Read more

How to detect a remote side socket close? [duplicate]

The isConnected method won’t help, it will return true even if the remote side has closed the socket. Try this: public class MyServer { public static final int PORT = 12345; public static void main(String[] args) throws IOException, InterruptedException { ServerSocket ss = ServerSocketFactory.getDefault().createServerSocket(PORT); Socket s = ss.accept(); Thread.sleep(5000); ss.close(); s.close(); } } public class … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)