Hi guys, I am trying to make a chat bot on Omegle, (sort of line SmarterChild on MSN, but for Omegle). Anyway, my problem is when I send my HTTP post, I am not receiving any data. I call recv, but it does not send me any data. When I send the same headers with telnet, everything works fine.
Here is my source code, I think I have to add something at the end of my string. Omegle uses TwistedWeb as their web server. Here is my source code:
main.h
#ifndef main_h
#include <winsock2.h>
#include <windows.h>
#include <stdio.h>
char header1[] = "POST /start?rcs=1 HTTP/1.1\nHost: omegle.com\nUser-Agent: FireFox/1.0\nContent-Type: application/x-www-form-urlencoded\nContent-Length: 0\n";
#define main_h
#endif
main.cpp
#include "main.h"
int OmegleBot(char* header1);
int main()
{
OmegleBot(header1);
system("pause");
return 0;
}
int OmegleBot(char* header1)
{
INT nret;
SOCKADDR_IN addr;
LPHOSTENT hostEntry;
WSADATA wsaData;
SOCKET Socket;
CHAR OmegleID[20];
CHAR* token;
CHAR recvData[256];
if( WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR )
{
WSACleanup();
return 0;
}
hostEntry = gethostbyname("omegle.com");
if( !hostEntry )
{
WSACleanup();
return 1;
}
Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if( Socket == INVALID_SOCKET )
{
WSACleanup();
return 2;
}
addr.sin_family = AF_INET;
addr.sin_addr = *( (LPIN_ADDR)*hostEntry->h_addr_list );
addr.sin_port = htons(80);
nret = connect( Socket, (LPSOCKADDR)&addr, sizeof(struct sockaddr) );
if( nret == SOCKET_ERROR )
{
WSACleanup();
return 3;
}
send(Socket, header1, strlen(header1), 0);
printf(header1);
printf("\n\n");
recv(Socket, recvData, 256, 0); //Program is stuck here, doesnt recv anything.
printf(recvData);
WSACleanup();
}
To sum it all up, how come my program does not receive any data? What do I have to change to receive the response of my post?