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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:21:56+00:00 2026-05-24T19:21:56+00:00

I’m going to setup a small client/server server in TCP/IP mode, I use VS2010,C#

  • 0

I’m going to setup a small client/server server in TCP/IP mode, I use VS2010,C# to develop my apps, I’ve googled a lot and could find some source codes, but none of them work in internet, I can get some answers in my own local system, i.e. I run my server, then listen for my own localhost (127.0.0.1) then send some data (for example using telnet), it works fine but when I do the same over internet I get nothing! I want to use port 80, as I want to send/receive http data, I have tested several source codes, here is the last code I have used (and it works on localhost with telnet)

//server code:

form_load()
    IPAddress localAddress = IPAddress.Parse("127.0.0.1");
                Socket listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint ipEndpoint = new IPEndPoint(localAddress, 80);

            // Bind the socket to the end point
            listenSocket.Bind(ipEndpoint);

            // Start listening, only allow 1 connection to queue at the same time
            listenSocket.Listen(1);
            listenSocket.BeginAccept(new AsyncCallback(ReceiveCallback), listenSocket);
            Console.WriteLine("Server is waiting on socket {0}", listenSocket.LocalEndPoint);

            // Start being important while the world rotates
            while (true)
            {
                 Console.WriteLine("Busy Waiting....");
                Thread.Sleep(2000);
            }

        public static void ReceiveCallback(IAsyncResult AsyncCall)
    {
         System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
        Byte[] message = encoding.GetBytes("I am a little busy, come back later!");

        Socket listener = (Socket)AsyncCall.AsyncState;
        Socket client = listener.EndAccept(AsyncCall);

        Console.WriteLine("Received Connection from {0}", client.RemoteEndPoint);
        client.Send(message);

        Console.WriteLine("Ending the connection");
        client.Close();
        listener.BeginAccept(new AsyncCallback(ReceiveCallback), listener);
    }

send data (client), of course I haven’t used this code, is it right?

        public static string SendData()
    {
        TcpClient client = new TcpClient();
        client.Connect(IP, 80);
        StreamWriter sw = new StreamWriter(client.GetStream());
        StreamReader sr = new StreamReader(client.GetStream());

        //if statement evalutes to see if the user has selected to update the server
        //" " = update server
        //"" = do not update the server
        //if (updateData.Equals(""))
        //{
        //    space = "";
        //}
        //else if (!updateData.Equals(""))
        //{
        //    space = " ";
        //}
        //Refrences stream writer, username variable passed in from GUI
        //space variable provides update function: "" = dont update. " " = update database.
        sw.WriteLine("h");
        sw.Flush();
        //data send back from the server assigned to string variable 
        //string recieved = sr.ReadLine();
        return "";

    }

I’m going to have the server code in my Server (winserver 2008R2) but currently test it in normal PCs, what am I doing wrong? I want to send some http packet from a random system (with a random IP) to my server (which I know its IP), what should I do? is it possible with tcp/ip or I should do something else?
is it related to static IP? should I certainly have static IP? my web server has a static IP but my clients do not, is it a problem?
I think I have some problem in defining ports and IPs, how should I set them? my server has a specific IP, but I don’t know IP of my clients, would you please explain it to me step by step?
thanks

  • 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-24T19:21:56+00:00Added an answer on May 24, 2026 at 7:21 pm

    The two most common problems in this scenario:

    1. Ensure your server’s router is using port forwarding to forward HTTP requests from the router to the server.
    2. Ensure you are connecting to the server’s public IP address, not its local network address.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.