How do i find out if a client connected to a server??

if its connected i want to display a message box says "You are now connected" else i want to display "You are not connected"