1) connect TOR through socks port(localhost:9050 default) from your c# application (TCP/IP)
Here is a simple c code .hope this will help..
############################################################
//Create socket for client.
sockfd = socket(PF_INET, SOCK_STREAM, 0);
if (sockfd == -1) {
perror("Socket create failed.\n") ;
return -1 ;
}
//Name the socket as agreed with server.
address.sin_family = AF_INET;
address.sin_addr.s_addr = inet_addr("127.0.0.1");
address.sin_port = htons(9050);
len = sizeof(address);
result = connect(sockfd, (struct sockaddr *)&address, len);
//#######################################STEP1 DONE#######################
char buf[1024];
send(sockfd,"\x05\x01\x00",3,0); // \x05= SOCKS5, \x01=NEXT BYTE LENGTH,\x00= NO AUTHENTICATION
int bytes_recv = recv(sockfd, buf,sizeof(buf),0);
if ((buf[0] != 5) || buf[1] == 0xFF)
{
return 1;
}
//####################################NEGOTIATION 1 DONE###############
\\05=SOCKS5,01=CONNECT,00=reserved,03=DOMAIN,
\\ \x77\x77\x77\x2e\x67\x6f\x6f\x67\x6c\x65\x2e\x63\x6f\x6d =
www.google.com \\ \x00\x50 == port(80)
send(sockfd,"\x05\x01\x00\x03\x0e\x77\x77\x77\x2e\x67\x6f\x6f\x67\x6c\x65\x2e\x63\x6f\x6d\x00\x50",21,0);
bytes_recv = recv(sockfd, buf,sizeof(buf),0);
//####################################NEGOTIATION 2 DONE ################
char request[1024] = "GET / HTTP/1.1\r\nHost:
www.google.com\r\n\r\n";
send(sockfd,request,sizeof(request),0);
int bytes_recieved =0;
bytes_recieved = recv(sockfd, buf, 1024, 0);
buf[bytes_recieved] = '\0';
cout<<buf<<endl;
############################### SENDING HTTP GET AND GETTING HEADER AS ANSWER #####