Thread: need your help

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    14

    need your help

    im trying to figure out what this means. its problably not compliated at all but my c programming is a little rusty.

    bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr));

    ok i get lost at the (srtruct sockaddr *)&my_addr
    whats that * doing is it pointing to something. just explain that one bit of code to me. thanks.
    peace out

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It's a type cast. The line:

    (srtruct sockaddr *)&my_addr

    states:

    "The address of variable 'my_addr', is a pointer of type 'struct sockaddr'."

    If you aren't sure what a type cast is, it's when you tell one variable type that it's actually another one.

    I believe here, your sturcture is 'struct sockaddr_in' or something similar, and you're telling the function that it is just a 'sockaddr' structure.

    Quzah.
    Last edited by quzah; 07-22-2002 at 11:15 PM.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed
Website Security Test