Thread: msgsnd : Invalid argument

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    9

    msgsnd : Invalid argument

    G'day, everyone!

    My another issue is the following.

    I have a server-client program that makes use of the message queues: clients communicate with each other centralizedly through the server; obviously, they use the same queue. Kind of a local instant messaging service with a basic set of functions. In the beginning the client registers and the server sends it a confirmation.

    It works pretty well when I run it on my computer. But when I tried to execute it on the other system and send a message from the server, I immedeately got it crashed with the following error:

    Code:
    msgsnd : Invalid argument
    This is what I got when I STFW'd

    Two conditions can cause that error:
    1. message queue identifier is not valid
    2. message length is less than zero
    But:

    1. the client DOES register at server, therefore it uses msgsnd() successfully; the server uses the same queue; yet, the program crashes as soon as server attempts to use msgsnd(). I use my own header as an argument for ftok();
    2. the content of message is just fine.

    I don't get it. My question is, what could change when I switched from one system to the other?

    Thanks in advance!
    Last edited by Krusty; 09-10-2009 at 11:53 AM.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Did you have to compile separately on the two systems or are you using the same executable on both of them?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Compiled separately on each system.
    Forgot to mention it.

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Krusty View Post
    Compiled separately on each system.
    Forgot to mention it.
    In that case, it is possible that you have a buffer overflow which shows up using one compiler and not the other, since there are probably small differences in the way they arranged memory. That could invalid the identifier, I guess.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Nested loop frustration
    By caroundw5h in forum C Programming
    Replies: 14
    Last Post: 03-15-2004, 09:45 PM
  5. Flood of errors when include .h
    By erik2004 in forum C++ Programming
    Replies: 14
    Last Post: 12-07-2002, 07:37 AM