How to detect PC connect to my USB Device

I configure usb as mass storage device.
I don't know how I can detect PC connection to my usb port.

More questions in this forum