binding sockets and pointer types

Discussion in 'C Programming' started by Guillaume Yziquel, Jun 21, 2007.

  1. Hello all.

    I wish to bind a socket with the following code:

    > if (bind(s, (struct sockadrr *) serversocket, sizeof(serversocket)) != 0) {
    > perror("Failed to bind the server socket to a file.");
    > exit(1);
    > };


    where serversocket is declared with

    > struct sockaddr_un serversocket;


    At compile-time, I get:

    > main.c:29: warning: passing argument 2 of ´bind´ from incompatible pointer type.


    I do not really understand how to get rid of this warning.

    Guillaume.
     
    Guillaume Yziquel, Jun 21, 2007
    #1
    1. Advertising

  2. Guillaume Yziquel a écrit :
    > Hello all.
    >
    > I wish to bind a socket with the following code:


    Oh. I forgot to mention: I'm trying to use Unix-domain sockets, not
    TCP/IP sockets. I've been trying to follow what has been written on:

    www.ecst.csuchico.edu/~beej/guide/ipc/usock.html

    Guillaume.
     
    Guillaume Yziquel, Jun 21, 2007
    #2
    1. Advertising

  3. In article <f5duqq$2hms$>,
    Guillaume Yziquel <-francaise> wrote:

    > if (bind(s, (struct sockadrr *) serversocket, sizeof(serversocket)) != 0) {


    Assuming this is cut-and-pasted from your program, the problem is that
    you have misspelled "sockaddr" as "sockadrr".

    -- Richard
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
     
    Richard Tobin, Jun 21, 2007
    #3
  4. Richard Tobin a écrit :
    > In article <f5duqq$2hms$>,
    > Guillaume Yziquel <-francaise> wrote:
    >
    >> if (bind(s, (struct sockadrr *) serversocket, sizeof(serversocket)) != 0) {

    >
    > Assuming this is cut-and-pasted from your program, the problem is that
    > you have misspelled "sockaddr" as "sockadrr".


    You assumed right. Thank you: that was the last thing I were to think of...

    Guillaume.
     
    Guillaume Yziquel, Jun 21, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcus Alanen
    Replies:
    1
    Views:
    336
    Alf P. Steinbach
    Sep 7, 2003
  2. Replies:
    10
    Views:
    717
    Chris Torek
    Feb 4, 2005
  3. jimjim
    Replies:
    16
    Views:
    852
    Jordan Abel
    Mar 28, 2006
  4. Replies:
    11
    Views:
    1,411
    James Kanze
    Jun 7, 2007
  5. ittium
    Replies:
    4
    Views:
    310
    Goran
    Dec 9, 2011
Loading...

Share This Page