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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:29:09+00:00 2026-05-31T01:29:09+00:00

I try to print client port in my server application which is in C.

  • 0

I try to print client port in my server application which is in C.
But I get negative numbers of the Client port, what is strange behaviour:-/
Any one have an idea where could be a problem?
Part of my code which cause the problem:

struct sockaddr_in client_address;
int chosenPort = (int) ntohl(client_address.sin_port);
pritf("Client port is %d, chosenPort");

I get port like -2121400320.

  • 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-31T01:29:11+00:00Added an answer on May 31, 2026 at 1:29 am

    Use ntohs() instead – sin_port is a 16-bit value.

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

Sidebar

Related Questions

I have a little server.jar, which listen to GET and END command on port
I trying to write a client server application in Python, but I faced a
I have some Apache Thrift (v.0.6.1) test application with perl-server and php-client. The behaviour
I'm writting a client(Android) - server(c#) application. I get the code from here: How
When I try to print a string in a Windows console, sometimes I get
I have an array of double pointers, but every time I try do print
In Java, arrays don't override toString() , so if you try to print one
Because I didn't want to implement a communication protocol for my client-server based application,
Scenario. I have a client with two network connections to a server. One connection
I'm trying to send some data from the server to the client, but 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.