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 8014335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:54:09+00:00 2026-06-04T19:54:09+00:00

I have a program that transfer data over Internet sockets (UDP). so there are

  • 0

I have a program that transfer data over Internet sockets (UDP). so there are defined char arrays as data packets. E.g. char packet1[] = 11 (header[2 digit]) + 192.168.100.158 (sender_IP[15 digit]) + 006 (TTL [3 digit])+… (11192.168.100.158006...). The receiver extracts the data according to the index of the array (e.g. 0-1 is header, 2-16 is sender_IP).

My problem is that when I define the sender_IP as [2-16] and if the IP address is shorter than 15 digit (e.g. 192.168.100.5) then the receiver extracts the data wrong. My question is that how can I make sure that sender_IP would be extracted correctly even if the IP address is 15 digit or 14 digit (without adding extra character to define the string length of sender_IP)?

I was thinking to create a struct type and define something like `

struct packet {
   char header[1];
   char senderIP[15]
   , TTL[2];
  };

. but I could not figure out what to write instead of buf on this line sendto(s, buf, BUFSIZE, 0,(struct sockaddr *) &si_other, slen), since buf needs to be char as I know. I need the IP address in ASCII representation as send some data to sender_IP address (inet_aton(sender_IP, &si_other.sin_addr).

  • 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-04T19:54:11+00:00Added an answer on June 4, 2026 at 7:54 pm

    Send the IP’s as a 32-bit int, or pack the string with zeros so it is the proper length, e.g. 192.168.100.005.

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

Sidebar

Related Questions

I have a program that receives real time data on 1000 topics. It receives
I have a program that downloads PCM data from a Web Server, which it
I have a program that creates a JFrame and makes it visible. Is there
I have a simple file transfer socket program where one socket sends file data
I have an iPhone app that reads barcodes. I want to transfer that data
I am working on a reliable file transfer program that uses UDP. (for a
I am using vb.net 2010 and I have created a program that uses sockets
I have program that has a variable that should never change. However, somehow, it
I have program that runs fast enough. I want to see the number of
I have a program that works with a variety of files on both the

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.