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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:10:07+00:00 2026-05-31T21:10:07+00:00

in sys/socket.h it defines the function: int accept (int socket, struct sockaddr *address, socklen_t

  • 0

in “sys/socket.h” it defines the function:

int accept (int socket, struct sockaddr *address, socklen_t *address_len);

My question has to do with socklen_t *address_len which based on the manual points to a socklen_t which on input specifies the length of the supplied sockaddr structure, and on output specifies the length of the stored address.

Under what conditions will the address_len size input be different from output?

I need this so I can emulate a test case on a wrapper I have created for the sockaddr_in structure.

Thanks a lot!

  • 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-31T21:10:08+00:00Added an answer on May 31, 2026 at 9:10 pm

    It can never be more (the input length is a bounds to prevent overflows), but it could be less for certain socket types, for instance unix domain sockets whose addresses are essentially pathnames. For IP (v4 or v6) sockets, it will always be the nominal size of the corresponding sockaddr_in or sockaddr_in6 structure.

    Also note that it’s possible to use some interfaces like this without knowing what type of address/protocol family is involved. For instance you might have a function as part of your library code that takes a socket of unknown type and calls accept on it with a sockaddr_storage structure. It might find an IPv4 address, and IPv6 address, or something else entirely, depending on what the caller did.

    This usage is fairly non-typical for accept, but it’s a lot more likely for getpeername which uses the same interface style. In fact this is the way all daemons that run from inetd and which want to know the remote address must operate.

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

Sidebar

Related Questions

Sorry for a very generic sounding question. let's say #include <sys/socket.h> #include <sys/types.h> #include
Here is my server program #include<stdio.h> #include<stdlib.h> #include<sys/socket.h> #include<sys/un.h> #include<sys/types.h> #include<unistd.h> int main ()
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <stdio.h> void error(char *msg) {
Hey gang. I have just written a client and server in C++ using sys/socket.
RFC 793 says that TCP defines a push function that ensures that the receiver
folks please see following code : #include <gio/gio.h> #include <sys/socket.h> //socket(); #include <netinet/in.h> //sockaddr_in
I got a server class in server.h: namespace tcp{ #include <sys/types.h> #include <sys/socket.h> #include
I am including sys/socket.h, I still get compile time errors telling me that AF_INET
#import <sys/socket.h> #import <netinet/in.h> #import <arpa/inet.h> I have import the headers above,but setsockopt(CFSocketGetNative(TCPSocket), SOL_SOCKET,
I have the following libev code: #include <ev.h> #include <stdio.h> #include <errno.h> #include <sys/socket.h>

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.