Click here to Skip to main content
12,999,010 members (47,194 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi everyone!

I am having a strange problem when I try to connect to a server using a socket: It works when I do it from my home networks but it fails connecting when I do it from my school's public network which is as you may guess monitored.
My code:

        WSASATA init;
	info.sin_addr.s_addr=inet_addr("");   //Google's IP address
	connect(s,(struct sockaddr*)&info,sizeof(info));
        char resp[20001];
	int nbcaractere=recv(serveur,resp,20000,0);

Where aEnvoyer is a string containing a valid GET request.

The school may be blocking that kind of socket. I know that proxies are not used there.

So my question is: is this code problematic?
My second question is: What type of socket do firefox and iexplore use in order to communicate with HTTP servers?

Thank you very much.
Hoping I was clear,
Posted 29-Nov-10 7:14am
Richard MacCutchan 29-Nov-10 15:42pm
You do not really explain what happens when "it fails". Do you get an error somewhere, and if so what is the value? Does your program crash, do you get an exception, etc.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

1. This code is fine. Your school might have a firewall that blocks such requests.
2. HTTP works on TCP as its transport layer, so browsers use the transport layer sockets made available to them by operating system. Which in windows case will be Winsock.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Thank you for your reply.
Could you tell me how I can use these transport layer sockets?
In fact, I thought that I was already using Winsock. I've searched for that kind of info for a while, I tried some examples but none of them worked. Thanks!
Rate this: bad
Please Sign up or sign in to vote.

Solution 3


My guess would be that your school is using a transparent caching proxy. If this is the case then you are actually connecting to a proxy server such as squid[^]. Squid can be configured to block fake browser requests by inspecting the browser headers.

I would suggest that you forge ALL of the browser headers[^] and I suspect you will have better success.

Best Wishes,
-David Delaune

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 29 Nov 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100