Today, I wrote a small example of a System V message queue and defined a structure like this:
#define MSG_SIZE 8192struct request{ long mtype; int client_id; char pathname[MSG_SIZE];};
I then called msgsnd to send the struct to the server, but found an error:
MSGSND error, Invalid argument
Carefully check the incoming msgsnd each parameter, confirm that there is no problem ah, then this invalid argument is which parameter?
There is no way to read the msgsnd man manual again, see MSGSND error code einval when it seems to find that the problem is there:
EINVAL Invalid msqid value, or nonpositive mtype value, or Invalid msgsz value (less than 0 or greater than the system value MSGM AX).
The problem should be that the msgsz I sent exceeded the maximum msgmax of the system and look at the Msgmax of the system:
[Email protected]:~/station/tlpi/chapter_45$ Cat/proc/sys/kernel/msgmax
8192
The system's Msgmax is 8192, and I send the Msgsz 8196, exceeding the system's maximum value, so the error.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
A little problem with msgsnd