Hello,
I'm at the end with my knowledge. In cradle and in emulator it is possible
to connect and to load the file but via GPRS it isn't. recv returns -1
please help please help
thanks in advance
WSADATA WSAData;
hostent *h = NULL;
SOCKET s = INVALID_SOCKET;
sockaddr_in name;
try
{
if(0 != WSAStartup(0x0101,&WSAData))
throw(_T("WSAStartup(0x0101,&WSAData))"));
/*wchar_t x[51];
wsprintf(x,_T("%i"),WSAData.wVersion);
SetDlgItemText(IDC_STATIC1,x);*/
hostent *h = gethostbyname("www.pilskills.de");
if(NULL == h)
throw(_T("could not resolve hostname"));
s = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(INVALID_SOCKET == s)
throw(_T("socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);"));
name.sin_port = htons(80);
name.sin_family = AF_INET;
memcpy(&name.sin_addr.S_un.S_addr,h->h_addr_list[0],sizeof(4));
if(0 != connect(s,(SOCKADDR*) &name, sizeof(name)))
throw(_T("connect(s,(SOCKADDR*) &name, sizeof(name))"));
if(SOCKET_ERROR == send(s, "GET /index.html\r\n\r\n",sizeof("GET
/index.HTML\r\n\r\n"),0))
throw(_T("send(s, \"GET /index.HTML\r\n\r\n\",sizeof(\"GET
/index.HTML\r\n\r\n\")"));
char recvBuf[1000];
int bytesRecv = -99;
bytesRecv = recv(s,recvBuf,sizeof(recvBuf),0);
wchar_t z[101];
wsprintf(z,_T("bytesRecv %i"),bytesRecv);
SetDlgItemText(IDC_STATIC1,z);
WriteToLog(recvBuf);
if(0 != shutdown(s,0))
throw(_T("shutdown(s,SD_BOTH))"));
if(0 != closesocket(s))
throw(_T("closesocket()"));
if(0 != WSACleanup())
throw(_T("WSACleanup()"));
}
catch(wchar_t *except)
{
SetDlgItemText(IDC_STATIC1,except);
}
catch(...)
{
SetDlgItemText(IDC_STATIC1,_T("unhandled exception"));
}