PF_UNIX C perl
I'm trying to get a C program and a perl program to communicate over PF_UNIX local sockets, partly just because I've never done this before. I use sockaddr_un("name_of_file") and then connect
and I use print SOCK "data\n"; to send data. On the C side I'm using socket(PF_UNIX, SOCK_STREAM, 0), listening and then accepting the connection and there's a select loop to actually read the data.
The C program accepts the connection with no errors and then just sits there. It never reads the data. The perl program sends the data but then it just sits there, blocking on read. (The C program sends a response after it receives the data). There are no error messages and if I Ctrl-C the perl program, then the C program gets an MSGPIPE or whatever for a broken connection. But if I don't they just sit there indefinitely. At first I thought this was the perl programs fault, but it is sending the data according to it. The print statement doesn't die or anything, its blocking on the $line = <SOCK>; Then I thought it was the C program, but it does properly accept the connection. I'm wondering if anyone else has done anything like this and has some insight.
My second issue is that there is supposedly an abstract namespace for PF_UNIX sockets thats accessed by prefacing the name of the socket with a null. I don't want there to be a file, just a name in the socket namespace. Is perl okay with such things or is there a special better way to do this? I must have SOCK_STREAM because I need the C server to handle multiple such local connections simultaneously, not just one.
|