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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:12:15+00:00 2026-06-03T07:12:15+00:00

I have programed a server-client application as a RPC (low-level). This is my server

  • 0

I have programed a server-client application as a RPC (low-level).

This is my server function to validate my IP address (here, just the necessary information):

 int *checkip_1_svc(ip_adress *argp, struct svc_req *rqstp)
 {
     static int  result;
     struct sockaddr_in test_ip;

     result =1;

     return(&result);
 }

Now I want to print the IP address from the connected client.

I tried:

printf("Clientadress:%s", rqstp->rq_xprt->xp_raddr.sin_addr.s_addr);

This does not work. I get a segmentation fault.

  • 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-03T07:12:16+00:00Added an answer on June 3, 2026 at 7:12 am

    s_addr most propably is an unsigned 32bit integer, so you might use %u but %s:

    printf("client address: %u", rqstp->rq_xprt->xp_raddr.sin_addr.s_addr);
    

    To have it printed in the a.b.c.d notation you might use:

    #define SPLIT_S_ADDR_INTO_BYTES( \
        s_addr) \
        ((s_addr) >> 24) & 0xFF, \
        ((s_addr) >> 16) & 0xFF, \
        ((s_addr) >>  8) & 0xFF, \
        ((s_addr)      ) & 0xFF
    
    ...
    
    printf(
      "client address: %hu.%hu.%hu.%hu", 
      SPLIT_S_ADDR_INTO_BYTES(ntohl(rqstp->rq_xprt->xp_raddr.sin_addr.s_addr)));
    
    ...
    

    For details on ntohl() please see man ntohl().

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

Sidebar

Related Questions

I have a client / server application exactly like in this link. When I
I have a server and a client application, here's how it's currently implemented: The
i have application with client-server architecture. client (C program): generate various DER encoded data
I have a Client/ server application where the Server is in java and Client
I write Server for client-server application in C. I have to save logs to
I have an application using sockets.. a client and server program like mySql.. I
I have a client/server application for which it is beneficial to have the PC
I have client server application using distributed object. some time my code is working
I have a client/server program in TCP written in C, and I would like
all. I'm having a bit of weird problem with client server program. I have

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.