A little problem with msgsnd

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.