Added support for spcifying the socket
Only checks for socket if one is specified