0

I'm working on a client/server ftp program for a class using UNIX sockets in C. I have to send my data to this process my professor is having us use to simulate network traffic (called "troll"). It requires a special header. So I was going to try to make a struct with the header and then tack my data on to it... but my compiler keeps giving me this error...

"cannot convert to a pointer type" (referring to the last line of code)

I can not figure out what I am doing wrong...

/* make troll header */
    struct sockaddr_in dest, troll;
    struct {
        struct sockaddr_in header;
        char body[MAXDATASIZE];
    } message;
    message.header.sin_family = htons(AF_INET);
    message.header.sin_port = htons(SERVER_PORT);
    bcopy((char *)&server_name.sin_addr, (char *)&message.header.sin_addr, sizeof(server_name.sin_addr));

    troll.sin_family = AF_INET;
    troll.sin_port = htons(TROLL_PORT);
    bcopy((char *)&name.sin_addr, (char *)&troll.sin_addr, sizeof(name.sin_addr));

    /* send mini_buffer to troll */
    memcpy(message.body, mini_buffer, MAXDATASIZE);

    int result = sendto(troll_sock, (char *) &message, sizeof(message), 0, (struct sockaddr *) troll, sizeof(troll));

1 Answer 1

4

You need to pass the address of troll - not the the object itself. Try: ...(struct sockaddr *)(&troll)...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.