View topic - socket interfacing in resource manager

socket interfacing in resource manager

General Help about QNX

socket interfacing in resource manager

Postby priyanka » Mon Sep 07, 2009 12:46 pm

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);
}
priyanka
Active Member
 
Posts: 11
Joined: Thu Jul 16, 2009 4:42 am

RE: socket interfacing in resource manager

Postby mario » Mon Sep 07, 2009 3:16 pm

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.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Postby priyanka » Tue Sep 08, 2009 5:45 am

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.
priyanka
Active Member
 
Posts: 11
Joined: Thu Jul 16, 2009 4:42 am

Postby Thunderblade » Tue Sep 08, 2009 10:51 am

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.
Thunderblade
Senior Member
 
Posts: 489
Joined: Thu Apr 07, 2005 11:52 am

Postby priyanka » Tue Sep 08, 2009 11:05 am

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.
priyanka
Active Member
 
Posts: 11
Joined: Thu Jul 16, 2009 4:42 am

Postby Thunderblade » Tue Sep 08, 2009 12:30 pm

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.
Thunderblade
Senior Member
 
Posts: 489
Joined: Thu Apr 07, 2005 11:52 am

Postby xtang » Tue Sep 08, 2009 6:36 pm

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.
xtang
QNX Master
 
Posts: 313
Joined: Thu Jul 18, 2002 5:01 pm

Postby priyanka » Wed Oct 14, 2009 2:38 pm

thanks everyone
priyanka
Active Member
 
Posts: 11
Joined: Thu Jul 16, 2009 4:42 am


Return to Help

Who is online

Users browsing this forum: No registered users and 2 guests