c++ - accept() in message queues IPC UNIX -
for (;;) { if (msgrcv(msqid, &flag, sizeof(struct flags) - sizeof(long), 1, ipc_nowait)>0) break; } msgsnd(msqid, &message , sizeof(struct messages) - sizeof(long), 0); is there accept() function in sockets ipc, message queues ipc? server should wait client connection , when client connected send data it. special send client useless data , check data in infinity loop(that means client connected, know stupid algorithm).
no, there nothing directly analogous. message queues more connectionless datagram sockets connection-oriented stream sockets (which support accept() , forth).
some implementations (z/os?) expose number of processes blocked on msgrcv, similar looking for, not portable.
as see it, have 2 easy options.
first, doing don't ipc_nowait in server's msgrcv. no point in spinning in loop if you're not doing anything. block until client announces itself. (and use different message types communication client-to-server , server-to-client — don't want clients consuming messages server, nor vice-versa.)
second, switch af_unix stream sockets, give accept()able semantics.
Comments
Post a Comment