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

  • Home
  • SEARCH
  • 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 9116427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:40:13+00:00 2026-06-17T04:40:13+00:00

I am working on a C program to connect to a proxy and then

  • 0

I am working on a C program to connect to a proxy and then through the proxy pull data / send data to the website. I am confused however on what to do after I get the “CONNECT” statement to work.

My current Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>

#define maxlen 2048

int main(int argc, char *argv[])
{
int mysocket;
int len;
char buffer[2000];
char msg[] = "CONNECT http://example.com:80/ HTPP/1.0\r\n\r\n";


mysocket = socket(AF_INET, SOCK_STREAM, 0);

struct sockaddr_in dest;

memset(&dest, 0, sizeof(dest));

dest.sin_family = AF_INET;
dest.sin_addr.s_addr = inet_addr("101.255.60.162");
dest.sin_port = htons(3128);

connect(mysocket, (struct sockaddr *)&dest, sizeof(struct sockaddr));

send(mysocket, msg, strlen(msg), 0);
len = recv(mysocket, buffer, maxlen, 0);

buffer[len] = '\0';

printf("%s \n", buffer);
close(mysocket);
return 0;

I tried sending another command after that but when I send a second command it goes straight to the site and not through the proxy.

Thanks in advance!!

  • 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-17T04:40:14+00:00Added an answer on June 17, 2026 at 4:40 am

    First of all forget about the code and learn the packet flow. Use any packet capturing tool like wireshark for seeing the traffic. Setup a proxy in the browser and open some http site and observe first connect packet to proxy in wireshark. Select the connect packet, right click on it and select “Follow tcp stream”. That will open a new window and you can see the complete flow of packets there for that http request.

    Once you know the packet flow then rest of packets can be sent and received in the same way you have made the first CONNECT packet.

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

Sidebar

Related Questions

I am working on an Android 3.0 program that can connect to a SSL'd
is there any small working program for recieving from and sending data to client
I have a working program in C++ that generates data for a Mandelbrot Set.
I'm trying to get a simple winsock program working, so I create my socket
I'm working on a program that sends data to a server. The server is
I'm working on a simple c program that has to connect to my database,
I am trying setup a Java program to connect to a website of my
I'm working on a small Ruby program that will connect to a remote MySQL
I get the following error when my program attempts to connect to a URL
I'm working on a Python program that submits data to Mongolab, and I'm running

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.