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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:06:58+00:00 2026-06-12T05:06:58+00:00

I have written a simple c++ server/client chat application. I am interested in being

  • 0

I have written a simple c++ server/client chat application. I am interested in being able to have multiple clients speak to one another through the server (like a chat room). I would like this to be able to work over the internet and not just within my local network.

I am having trouble connecting to the server (the server is running on my desktop machine at home, which is connected via a wire to the modem).

The server has the following socket address settings:

addr.sin_addr.s_addr = inet_addr("127.0.0.1");
addr.sin_port        = htons(1234);
addr.sin_family      = AF_INET;

The client has the following socket address settings:

addr.sin_addr.s_addr = inet_addr("63.22.45.56");
addr.sin_port        = htons(1234);
addr.sin_family      = AF_INET;

I used the internet WAN IP Address of the desktop for the client to connect to.
I port forwarded “1234” in my router settings for both TCP/UDP. It is also pointing to the local IP address of my desktop (192.168.0.16)

I am not sure why it is not able to connect. Please feel free to look at my client and server code below.

https://dl.dropbox.com/u/12735155/chat_client.cpp (Note: the socket address is 127.0.0.1 here, but ignore that. I have updated it to 63.22.45.56)

https://dl.dropbox.com/u/12735155/chat_server.cpp

  • 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-12T05:06:59+00:00Added an answer on June 12, 2026 at 5:06 am

    You should specify 192.168.0.16 in your code instead of 127.0.0.1.

    This is because you do not want to listen on localhost, you want to listen on the IP address connected to the outside world. That’s why this code will work when you tell the client to connect to localhost, but it won’t work if you tell your client to connect to your WAN IP and the connection gets routed outside.

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

Sidebar

Related Questions

I have written a simple single threaded client server application in Visual C++ .
I have a simple UDP client server written in C++ on Ubuntu 9.10 where
I have written a simple web Application which is running(on Tomcat Server) fine on
I have written a simple server - client program with Swing interface using singleton
I have a written a simple Client-Server pair, sending an Object to the server.
I have written a simple TCP client and server. The problem lies with the
i have written simple client server socket programming code as follow MyServer.java import java.io.DataInputStream;
I have written client-server application in C. I run the server in linux. I
I have written a simple client server program in C under linux. I have
I have written a simple SSL Client/Server set of programs from a few tutorials

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.