Sockets – Win32 Sockets vs. Named Pipes

named-pipessocketswinapi

Is it possible to use sockets on Win32 and not have the firewall possibly block the port you are using?

In Unix, you can use IF_UNIX instead of IF_INET (i.e. named pipes instead of sockets). Right now in Windows you can open a socket using different protocols:

socket(AF_INET,    SOCK_RAW, IPPROTO_TCP);     //open an IPv4 socket
socket(AF_BTH,     SOCK_RAW, BTHPROTO_RFCOMM); //open a Bluetooth socket
socket(AF_NETBIOS, SOCK_RAW, IPPROTO_TCP);     //open an IPX/SPX socket
socket(AF_INET6,   SOCK_RAW, IPPROTO_TCP);     //open an IPv6 socket

Is there any way to open a named pipe socket? E.g. (hypothetical construct)

socket(AF_NAMEDPIPE, SOCK_RAW, IPPROTO_TCP);   //open a named pipe socket

Best Answer

As John Cavan (who I think I once went to school with) says, using the loopback address should avoid the NIC and firewall altogether, and also gives you the ability of changing to a full client-server model (i.e. separate machines, possibly on different platforms) later on with minimal code changes.

I have also used shared memory successfully for same-machine communications. This is generally faster that TCP/IP and named pipes. However, I have found named pipes on Win32 to be reliable and relatively fast.

Related Topic