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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:19:03+00:00 2026-05-30T22:19:03+00:00

int server_sockfd, client_sockfd; //server and client filedescriptors socklen_t server_len, client_len; struct sockaddr_in server_address; //server

  • 0
    int server_sockfd, client_sockfd; //server and client filedescriptors
    socklen_t server_len, client_len; 
    struct sockaddr_in server_address; //server address
    struct sockaddr_in client_address; //client address
    int server_port = 10000;
    char *def_server_address ="127.0.0.1";

    server_len = sizeof(server_address);
    memset(&server_address, 0, server_len );
    server_address.sin_family = AF_INET;

    if (x == 1) {
        server_address.sin_addr.s_addr = INADDR_ANY;}
    else {
        server_address.sin_addr.s_addr = inet_addr(def_server_address);
    }
    server_address.sin_port = htons(server_port);

How should I print the address of the server from server_address? Using printf.

  • 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-30T22:19:04+00:00Added an answer on May 30, 2026 at 10:19 pm

    Use inet_ntop() to convert it to a string

    This function converts the network address structure src in the af
    address family into a character string. The resulting string is
    copied to the buffer pointed to by dst, which must be a non-null
    pointer. The caller specifies the number of bytes available in this
    buffer in the argument size.

    inet_ntop() extends the inet_ntoa(3) function to support multiple
    address families, inet_ntoa(3) is now considered to be deprecated in
    favor of inet_ntop().

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

Sidebar

Related Questions

I got a struct for client and server like this: { char type; int
UDP_SERVER int main() { int sockfd,clilen; char arr[20]; struct sockaddr_in serv_add,cliaddr; if((sockfd=socket(AF_INET,SOCK_DGRAM,0))<0) printf(error); bzero((char
in SQL Server, if I have an int variable, how can I write a
I have a sql server table: CREATE TABLE [Workflow].[MilestoneDate]( [MilestoneDateId] [int] IDENTITY(1,1) NOT NULL,
Is there a 4 byte unsigned int data type in MS SQL Server? Am
SQl Server 2005: Option: 1 CREATE TABLE #test (customerid, orderdate, field1 INT, field2 INT,
I have a table in SQL Server 2005 which has three columns: id (int),
I have a stored proc on sql server 2008 that excepts a int parameter.
Please consider the following SQL Server table and stored procedure. create table customers(cusnum int,
Consider this example table (assuming SQL Server 2005): create table product_bill_of_materials ( parent_product_id int

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.