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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:35:22+00:00 2026-05-22T21:35:22+00:00

I am writing a network program where, in the server part, I want to

  • 0

I am writing a network program where, in the server part, I want to accept connections from multiple clients using a listening socket. So I declare an array of address structs like this:

struct sockaddr_in* client;

which I create using malloc and later on, to accept connections I type:

newsock = accept(fd_skt, (struct sockaddr *)&client[i], &(sizeof(client[i])));

and there I get "lvalue required as unary '&' operand" from the compiler. Can anyone figure out what I have done wrong?

  • 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-05-22T21:35:22+00:00Added an answer on May 22, 2026 at 9:35 pm

    Yes, you can’t take the address of something that isn’t an lvalue, that is an object with an address. The result of the sizeof operator is just a value, it isn’t an object with an address.

    You need to create a local variable so that you can take its address.

    E.g.

    socklen_t addrlen = sizeof client[i];
    newsock = accept(fd_skt, (struct sockaddr *)&client[i], &addrlen));
    

    As an aside, struct sockaddr_in* client; declares a pointer, not an array. To use client as an array you need to assign it to a dynamically allocated array at some point before the call to accept. I assume that this is what you are doing when you say “I create using malloc”.

    Alternatively you could actually declare client as an array.

    struct sockaddr_in client[MAX_CLIENTS];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an event-driven network server program. This program accepts connections from other processes
I'm writing a program that is accessed from a local network and also from
I'm writing a simple program to browse the local network and pass on filenames
I am writing a simple C# tcp client and server program. The server will
I'm writing a simple console client-server app using MSMQ. I'm attempting to run it
Purpose I am writing a network program in C (specifically gnu89 ) and I
I am writing a network C program where a client sends a block of
Abstract Syntax Notation I'm in the process of writing a network client and server,
I'm writing a program using the Managed WiFi API . Here's how I get
I'm using a Java program to POST some XML data from a remote client

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.