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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:19:40+00:00 2026-05-31T13:19:40+00:00

I am wanting to make a TCP server that listens on port 443 so

  • 0

I am wanting to make a TCP server that listens on port 443 so that it can receive HTTP requests and post back.

Right now I am using Apache & PHP to do this in the normal way, but is it possible to do this without a web server?

For instance I’ve built out a traditional TCP/IP client/server application in C# .NET. Is it possible to use this implementation to handle the HTTP requests instead of using a web server?

  • 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-31T13:19:41+00:00Added an answer on May 31, 2026 at 1:19 pm

    This project may help you to create a web server from scratch: MiniHttpd: an HTTP web server library using pure TCP/IP

    But instead of dealing with many unnecessary details such as parsing headers, compression, authentication, ssl etc. I would use the built-in HttpListener class.

    Here is a simplified(but working) multi-threaded WebServer

    void CreateWebServer()
    {
        HttpListener listener = new HttpListener();
        listener.Prefixes.Add("http://*:8080/");
        listener.Start();
    
        new Thread(
            () =>
            {
                while (true)
                {
                    HttpListenerContext ctx = listener.GetContext();
                    ThreadPool.QueueUserWorkItem((_) => ProcessRequest(ctx));
                }
            }
        ).Start();
    }
    
    void ProcessRequest(HttpListenerContext ctx)
    {
        string responseText = "Hello";
        byte[] buf = Encoding.UTF8.GetBytes(responseText);
    
        Console.WriteLine(ctx.Request.Url);
    
        ctx.Response.ContentEncoding = Encoding.UTF8;
        ctx.Response.ContentType = "text/html";
        ctx.Response.ContentLength64 = buf.Length;
    
    
        ctx.Response.OutputStream.Write(buf, 0, buf.Length);
        ctx.Response.Close();
    }
    

    EDIT

    I changed the server a little bit to make it host a RESTful WebService (MyService). It returns the the result as Json. You can call it as http://localhost:8080/?method=Calc&i=5&j=4 (I omitted many error checks for simplicity)

    public class MyService
    {
        public Result Calc(int i, int j)
        {
            return new Result() { Addition = i + j, Multiplication = i * j };
        }
    }
    
    public class Result
    {
        public int Addition { set; get; }
        public int Multiplication { set; get; }
    }
    
    void CreateWebServer()
    {
        MyService service = new MyService();
    
        HttpListener listener = new HttpListener();
        listener.Prefixes.Add("http://*:8080/");
        listener.Start();
    
        new Thread(
            () =>
            {
                while (true)
                {
                    HttpListenerContext ctx = listener.GetContext();
                    ThreadPool.QueueUserWorkItem((_) => ProcessRequest(ctx,service));
                }
    
            }
        ).Start();
    }
    
    void ProcessRequest(HttpListenerContext ctx,MyService service)
    {
        try
        {
            string responseText = Execute(ctx, service);
    
            byte[] buf = Encoding.UTF8.GetBytes(responseText);
    
            ctx.Response.ContentEncoding = Encoding.UTF8;
            ctx.Response.ContentType = "application/json";
            ctx.Response.ContentLength64 = buf.Length;
    
    
            ctx.Response.OutputStream.Write(buf, 0, buf.Length);
        }
        catch
        {
            ctx.Response.StatusCode = (int) HttpStatusCode.NotFound;
        }
    
        ctx.Response.Close();
    }
    
    string Execute(HttpListenerContext ctx, MyService service)
    {
        System.Collections.Specialized.NameValueCollection nv = HttpUtility.ParseQueryString(ctx.Request.Url.Query);
    
        MethodInfo mi = service.GetType().GetMethod(nv["method"]);
        object[] parameters =  mi.GetParameters()
                                 .Select(pi => Convert.ChangeType(nv[pi.Name], pi.ParameterType))
                                 .ToArray();
    
        return JsonConvert.SerializeObject(mi.Invoke(service, parameters));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a simple TCP server using Twisted ,which can do some
I'm wanting to make a component that inherits from rotate canvas using a storyboard.
Can IIS / ASP.NET make use of the TCP keepalive option to detect dead
I'm trying to make a small testing server for Bugzilla so I can test
I have the following website: http://driz.co.uk/taschen/ I'm wanting to make it so when a
I am creating a website that stores recipes. I am wanting to make a
I've got the following url route and i'm wanting to make sure that a
I have been wanting to make a circular preloader in my iPhone app, but
I'm looking to make a gallery of images and am wanting to know how
I'm wanting to incorporate HTML5 database storage into my web application to make it

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.