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

  • Home
  • SEARCH
  • 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 7772333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:51:54+00:00 2026-06-01T16:51:54+00:00

I am building a building server and a client programs. I am trying to

  • 0

I am building a building server and a client programs. I am trying to make them communicate via a socket (in case it is important I am writing on a 32-bit OS Linux and both the client and the server will be running on the same systems). Now, I have the next structs:

struct config_line {
    char name[MAX_WORD];   //1 byte
    int  time;             //4 bytes
};

struct config {
    struct config_line *lines; // 4 bytes, points to a struct of 8 bytes
    int count;                 // 4 bytes
};

configData is defined as followes

struct config configData; // global

I send that configData like this:

send (clients [scn], &configData, sizeof (configData), 0)

Now, inside my client program, when I try to access

configData.lines[configIndex].name

it segfaults on that line. Anyone has an idea why?

  • 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-01T16:51:56+00:00Added an answer on June 1, 2026 at 4:51 pm

    When you send the type config, it has space for a pointer of config_line, but does not contain the data in the (I assume) array dynamically allocated where that pointer points to.

    Then the client gets the config type, but it has invalid pointer value (on the client) as the array is not sent and the pointer is not set to that array. (The pointer is valid on the sender, but not on the client — they use separate memory space)

    You will either need to specify a fixed size array in config that can contain a max number of elements you will ever want to store (then the sending will contain that data), or send the contents of the dynamic array and parse it on the client side and set the config pointer to that array, so the dereferencing is valid

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

Sidebar

Related Questions

I'm building a simple client-server chat system. The clients send data to the server
I'm building a .NET remoting client/server that will be transmitting thousands of files, of
I'm building a client that talks to the http server. Now my client needs
What would be the most sensible choice for building a socket server application, assuming
I am building a client server application using Java Sockets (in Windows XP). For
I am building an C++ application server-client where the client sends an image (170kb)
I am building a server client model in C. The clients connects to the
I'm building a client and a server program that exchanges data over TCP and
I'm building client/server apllication on QT. I just want user to execute only one
I'm building a client-server application and I am looking at adding failover to 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.