Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7974121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:17:03+00:00 2026-06-04T08:17:03+00:00

I use the code on http://www.abc.se/~m6695/udp.html the code works fine, I can see that

  • 0

I use the code on http://www.abc.se/~m6695/udp.html

the code works fine, I can see that the message is sent and the server receives it. However, When I build the program, I get the following “passing argument 5 of ‘sendto’ from incompatible pointer type [enabled by default]” for the line “if (sendto(s, buf, BUFSIZE, 0, &si_other, slen)==-1){“. I would appreciate if anyone could tell me how to fix. thank you

    #define  MAXSTRINGLENGTH 128
#define BUFSIZE 512

void log_msg_send(char *message, char *next_hop);
    void log_msg_send(char *message, char *next_hop);

int main(int argc, char** argv) {
    char hello[] = "hello bitches";
    char next_hop[]= "192.168.1.178";
    log_msg_send(hello, next_hop);
}

void log_msg_send(char *message, char *next_hop){
    char SRV_IP[16]; 
    strcpy(SRV_IP,  next_hop);

         struct sockaddr_in si_other;
         int s, i, slen=sizeof(si_other);
         char buf[50] ;
         strcpy(buf, message);

        if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1){
          fprintf(stderr, "inet_aton() failed\n");
          exit(1);
        }

        memset((char *) &si_other, 0, sizeof(si_other));
        si_other.sin_family = AF_INET;
        si_other.sin_port = htons(33333);
        if (inet_aton(SRV_IP, &si_other.sin_addr)==0) {
          fprintf(stderr, "inet_aton() failed\n");
          exit(1);
        }
          printf("Sending the packet %d\n", i);
          if (sendto(s, buf, BUFSIZE, 0, &si_other, slen)==-1){
          fprintf(stderr, "inet_aton() failed\n");
          exit(1);
        }

        close(s);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:17:04+00:00Added an answer on June 4, 2026 at 8:17 am

    Quick fix:

    sendto(s, buf, BUFSIZE, 0, (struct sockaddr *)&si_other, slen)
    

    This conversion is required because sendto() expects a pointer to struct sockaddr as its fifth argument while your particular socket address type is struct sockaddr_in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to use C2DM client with this tutorial:http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html I'm using this code for
Please see the attached image: 1) I downloaded a new library here: ( http://www.java2s.com/Code/Jar/ABC/Downloadcommonslang24jar.htm
Code: http://jsfiddle.net/n3mcH/ I use http://www.cssstickyfooter.com/using-sticky-footer-code.html . The footer is attached to the bottom, but
What url do you use for it because http://www.red5.org/projects/red5plugin/update_0.1.x/ gots redirected to http://code.google.com/p/red5/ ,
I use BBC carousel http://www.bbc.co.uk/glow/docs/1.7/furtherinfo/widgets/carousel/ . Here is my script code <script src=/themes/javascript/glow/1.7.7/core/core.js type=text/javascript></script>
Any time I use the recipe at http://code.activestate.com/recipes/134892/ I can't seem to get it
I have a HTML code which looks like this. <html><head><meta http-equiv=refresh content=0;url=http://www.abc.com/event/></head></html> I want
I use this code http://www.openjs.com/scripts/events/keyboard_shortcuts/index.php for handling keyboard shortcuts. shortcut.add(Ctrl+Z,function() { setTimeout(function() { var
In a remote site, there is a HTML file (say http://www.example.com/abc.html ), which reads:
I read this article, the parts of Intellisense and Generated Code: http://www.charlespetzold.com/etc/DoesVisualStudioRotTheMind.html Do you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.