Re: A quick socket question

joe_at_invalid.address
Date: 09/27/03


Date: Sat, 27 Sep 2003 15:46:55 GMT

captainblak2000@yahoo.com writes:

[followup to comp.lang.c not honored, they'll just tell you to go
away]

> I am new to socket programming and have this declaration here.
>
> #include <sys/socket.h>
> #include <sys/types.h>
> #include <string.h>
>
> #define DEST_IP "192.168.0.3"
> #define DEST_PORT 23
>
> int main (void)
> {
> struct sockaddr_in dest_addr;
> ...
> }
>
> when i compile with gcc i get
> socktest.c: In function `main':
> socktest.c:10: storage size of `dest_addr' isn't known
>
> what is the problem and how do i solve it?

The problem is that you didn't include the header file that declares
struct sockaddr_in, which is <netinet/in.h>. The solution is to
include it.

When the compiler tells you that something is of unknown size, or is
an icomplete type, that's usually what happened.

Joe



Relevant Pages

  • Re: extern variable
    ... I compile like gcc file1.c file2.c file3.c? ... Wherever gcc likes to put it. ... externs back where they belong. ...
    (comp.lang.c)
  • Re: pointer q
    ... int main (void) ... it would compile what you wanted was: ... a type compatible with the effective type of the object, ...
    (comp.lang.c)
  • Re: compiling error
    ... How to make it compile? ... void open_file ... int buf; ... Okay arrays when passed to function should not have the index but the ...
    (comp.lang.c)
  • Re: Variable Scope ?
    ... If you are using gcc, I recommend you to check compile options. ... The dynamic loader resolves the GOT entries when the pro- ... int shared_test{ ...
    (comp.lang.c.moderated)
  • Re: Writing to text segment
    ... memcpy((void *)&foo, buf, sizeof buf); ... Because it won't compile? ... volatile int i = 1; ...
    (comp.lang.c)