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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:42:53+00:00 2026-05-26T22:42:53+00:00

I want to create a tcp connection to a web server using information that

  • 0

I want to create a tcp connection to a web server using information that I get from a packet like the one shown below. To do this I need the hostname and portno from the packet to get an address that I can use with the connection function

This is assuming that I am using c++
Can I assume that the portno to talk to a server to request for html pages will be 80?
How do I get the hostname from the packet assuming that the packet is in the form of char array? I currently extract the string of characters bits.wikimedia.org and using that as the hostname. Is that correct?
Once I have the host name, I assume that I pass it in to getaddrinfo and use the structure that I passed in along with this function to generate a struct containing information understandable to the connect function. Is this assumption correct?

GET http://bits.wikimedia.org/en.wikipedia.org/load.php?debug=false&lang=en&modules=site&only=scripts&skin=vector&* HTTP/1.1
Host: bits.wikimedia.org
Proxy-Connection: close
User-Agent: Mozilla/5.0 (compatible; Konqueror/4.6; Linux) KHTML/4.6.5 (like Gecko) Fedora/4.6.5-7.fc15
Referer: http://en.wikipedia.org/wiki/Firewall_(computing)
Accept: */*
Accept-Encoding: x-gzip, x-deflate, gzip, deflate
Accept-Charset: utf-8, utf-8;q=0.5, *;q=0.5
Accept-Language: en-US,en;q=0.9
  • 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-26T22:42:54+00:00Added an answer on May 26, 2026 at 10:42 pm

    You should be able to rely on the Host: header field to have the host name in it.

    Look at the link to see how this is formatted. You need to read the header line by line, identify the “Host:” line, extract the following string, possibly extract the port number if given (host:port).

    Yes, getaddrinfo() could be used to obtain an IP address(es) for the host name.

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

Sidebar

Related Questions

I want to create a simple http proxy server that does some very basic
I want to create a TCP socket that listens only on a specific interface
I want to send a message to my computer from my phone using TCP..My
I want to create a new net.tcp://localhost:x/Service endpoint for a WCF service call, with
So I created a TCP\HTTP server (IN C#). I want to give to it
I want to create a Java application bundle for Mac without using Mac. According
I want to create a client side mail creator web page. I know the
I want to create a function that performs a function passed by parameter on
I'm writing a very small and simple server that I want to listen on
I've got a WCF service and want to connect to it using a TCP

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.