socket interfacing in resource manager

my application is using sockets to read and write data to the driver, but im confused how to map these to the posix open(),read()…to be used in resource manager.
The main problem is how to solve the pathname resolution during the open call as sockets use socket() & dont specify /dev/filename to be opened .
so how to map this.

i’ve tried this code in resource manager but its not working.

if (sockenv = getenv(“SOCK”))
{
sockname = alloca(sizeof(SOCKET_PREFIX) + 8 + strlen(sockenv)); // sizeof(char) == 1
strcpy(sockname, sockenv);
strcat(sockname, SOCKET_PREFIX);
sockenv = (char *)(sockname + sizeof(SOCKET_PREFIX) + strlen(sockenv) - 1);
}
else
{
sockname = alloca(sizeof(SOCKET_PREFIX) + 8 ) ;
strcpy(sockname, SOCKET_PREFIX);
sockenv = (char *)(sockname + sizeof(SOCKET_PREFIX) - 1);
}

If the driver uses socket then you driver must use sockets as well, which is shouldn’t be a problem. However you @could@ have you driver make it believe it’s a TCP/IP stack, but that would be probably risky, because that interface is not really documented and could change.

actually i wanted to ask like my appllication does
socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)

SO HOW WOULD THIS INVOKE THE OPEN FUNCTION IN RESOURCE MANAGER, I’VE SET THE FLAGS AND ATTRIBUTES ACCORDINGLY.

iofunc_attr_init (&attr, _S_IFSOCK | 0666, 0, 0);
resmgr_id = resmgr_attach (dpp, &resmgr_attr,sockname, _FTYPE_SOCKET , 0 ,&c_func, &io_func, &attr);

HOW WOULD THE PATHNAME RESOLUTION TAKE PLACE SO CALLS ARE DIRECTED TO MY RESOURCE MANAGER.

Sorry, but it’s not clear what you want to do, or why.

You want to “map” a socket call to an open call? If you are porting an application, why not just changing from the socket call to the open call?

Or, for some reason, you do not want to change the code of your app? But if you don’t want to change it, how do you want to enforce a “mapping” of calls? Is it that the application should be OS independent? Even then, POSIX calls exist in many systems, so…

The only thing you could do would be to write a “man in the middle” that accepts the socket calls and based on some name/number related to the socket opens the corresponding driver.

im writing a network driver which must accept data from the client application through sockets.
So my doubt is how to provide this socket interfacing in my resource manager to communicate with the client application.

Oh! In the case of a network driver, you typically do not write a resource manager. You use the network driver source code that QNX provides through their “Foundry27” (a maze of projects, wikis, forums and source code - search for the Networking Project). There also should be docs on how to use the source to develop your own driver.

The libsocket source is on Foundry27, so you can just grab that, and see how “socket()” call is implemented.

A socket() call will connected to the socket layer in TCPIP stack, it does not connect to driver. If you are writing a driver, there is no restriction of pathname. Your driver can advertise anything “/dev/mydriver”, and have your client use “open()” to connect to your driver.

Unless you are writing a specific “protocol layer”, it doesn’t sounds right to ask your client use “socket()” call to access your driver.

thanks everyone