Q:
I am using Linux-Mandrake 8.1. Using the Advanced Editor to edit my
programs and GCC in the BASH shell to compile them.
I am trying to pass a message structure into the send() and recv()
functions.
The message structure is as follows:
struct msgstruct {
unsigned short msgType;
unsigned from;
unsigned to;
char msg[250];
} msgStruct;
I enter input via scanf() for 'from'.
Initialize other values like:
msgStruct.from=htonl(100);
etc.
and in the function I call send():
send(socket,&msgStruct,sizeof(msgStruct),0);
When I compile: "gcc -o client client.c"
I receive this error:
"Storage size 'msgStruct' not declared.
What does this mean?
I want the program to pass the 'msgBuf' structure and send it to the
server so I can then receive it back and print what info I want to.
A:
I know what the error message means, but I do not know why you get it. You
did not supply the whole code, only fragments, and as I tried to reproduce
the program:
#include <stdio.h>
struct msgstruct {
unsigned short msgType;
unsigned from;
unsigned to;
char msg[250];
} msgStruct;
main(){
int socket;
send(socket,&msgStruct,sizeof(msgStruct),0);
}
was compiled fine (although it certainly does nothing).
Regards,
Peter
[ back to toc ]