"Protocol wrong type for socket": this errno generally occurs on socket system calls, such as connect. It occurs when the protocol type (SOCK_STREAM, SOCK_DGRAM, etc.) does not coincide between two sockets when a connection attempt is made. For example, I may create a datagram Unix socket with the name "/tmp/foo"; you will get this error if you try to connect to "/tmp/foo" with a stream socket you've created.