#147847 - chatterbug89 - Sat Dec 29, 2007 1:22 am
EDIT2: After a few hours, it seems to be working again how it use to work on the DS. Though, this behavior still seems weird considering it worked on multiple computers just fine (all of my network).
I am working on a project for the Nintendo DS that communicates with a PHP script on my host. Things were working perfectly for the most part but now suddenly my program cannot communicate with my host at all.
First of all, before I continue, I should note I'm using PA_Lib and it's PA_GetHTTP function.
Now, here's what's really weird. Placing the script on my personal server and having the DS execute it works great, but it just hangs when executing the exact same script on my server (that use to work yesterday). Running the PHP script from my browser works perfectly on the other hand.
Another odd thing that I have had to deal with is PA_GetHTTP seems to return some "junk" about the length of the incomming data when receiving data from the host in question (which is Total Choice Hosting). However, this extra data doesn't seem to be present when getting pages from my personal server and this extra data never shows up when using a web browser.
I'm just completely stumped as to why my host would be giving me such weird problems. I may just end up finding somewhere else to host my PHP app that communicates with my project (my personal server's connection is a tad slow and unreliable...).
Here is the PA_Lib function in question....the problem most likly lies in it.
Any suggestions, tips, or help would be appreciated. The site in question where the file is hosted is at cybernetresources.com.
EDIT: I have done numerous tests by just calling PA_GetHTTP and the bare-bones of what needs to be called to get things up and running. So...the problem shouldn't lie in my code at all. PA_GetHTTP simply hangs when it tries to get pages from my host.
I am working on a project for the Nintendo DS that communicates with a PHP script on my host. Things were working perfectly for the most part but now suddenly my program cannot communicate with my host at all.
First of all, before I continue, I should note I'm using PA_Lib and it's PA_GetHTTP function.
Now, here's what's really weird. Placing the script on my personal server and having the DS execute it works great, but it just hangs when executing the exact same script on my server (that use to work yesterday). Running the PHP script from my browser works perfectly on the other hand.
Another odd thing that I have had to deal with is PA_GetHTTP seems to return some "junk" about the length of the incomming data when receiving data from the host in question (which is Total Choice Hosting). However, this extra data doesn't seem to be present when getting pages from my personal server and this extra data never shows up when using a web browser.
I'm just completely stumped as to why my host would be giving me such weird problems. I may just end up finding somewhere else to host my PHP app that communicates with my project (my personal server's connection is a tad slow and unreliable...).
Here is the PA_Lib function in question....the problem most likly lies in it.
Code: |
int PA_GetHTTP(char *buffer, char *adress) { int sock; char serveur[256]; char buffer3[256]; int pos = get_HTTP_serveur(serveur,adress); PA_InitSocket(&sock,serveur,80,PA_NONBLOCKING_TCP); char buffer2[256]; sprintf(buffer2, "GET %s HTTP/1.1\r\nhost: %s\r\nAccept: */*\r\n\r\n",adress+pos,serveur); send(sock,buffer2,256,0); strcpy(buffer,""); while(search_word(buffer3,"\r\n\r\n",0) == -1) { memset(buffer3,0,sizeof(buffer3)); recv(sock,buffer3,256,0); } int poshtml = search_word(buffer3,"\r\n\r\n",0)+4; strcat(buffer,buffer3+poshtml); while(search_word(buffer,"</html>",0) == -1 && search_word(buffer,"</HTML>",0) == -1) { memset(buffer3,0,sizeof(buffer3)); if(recv(sock,buffer3,256,0)<1) break; strcat(buffer,buffer3); } if(sock) closesocket(sock); //closesocket(sock); return 1; } |
Code: |
int get_HTTP_serveur(char *buffer, char *buffer2) { int i,depart=0; if(search_word(buffer2,"http://",0)!=-1) depart+=7; for(i = depart; buffer2[i] != '\0' && buffer2[i] != '/' && buffer2[i] != '\\'; i++) { buffer[i-depart]=buffer2[i]; } buffer[i-depart]='\0'; return i; } |
Code: |
int search_word(char *mot1, char *mot2, int depart){ int i,j,erreur=1; for(i=depart;i<strlen(mot1);i++){ if(mot1[i]==mot2[0]){ erreur=0; for(j=0;j<strlen(mot2);j++) if(mot2[j]!=mot1[i+j]) erreur=1; if(erreur==0) return i; } } return -1; } |
Code: |
int PA_InitSocket(int *sock,char *host,int port,int mode) { unsigned long ip; struct sockaddr_in servaddr; *sock = socket(AF_INET, SOCK_STREAM, 0); if(IS_INETADDR(host)) ip = PA_chartoip(host); else ip = *(unsigned long *)gethostbyname(host)->h_addr_list[0]; servaddr.sin_family = AF_INET; servaddr.sin_port = htons(port); servaddr.sin_addr.s_addr = ip; if(mode == PA_NORMAL_TCP) { if(connect(*sock, (struct sockaddr *) &servaddr, sizeof(servaddr))==0) return 1; } else if(mode == PA_NONBLOCKING_TCP) { if(connect(*sock, (struct sockaddr *) &servaddr, sizeof(servaddr))==0) { int i = 1; ioctl(*sock, FIONBIO, &i); return 1; } } return 0; } |
Any suggestions, tips, or help would be appreciated. The site in question where the file is hosted is at cybernetresources.com.
EDIT: I have done numerous tests by just calling PA_GetHTTP and the bare-bones of what needs to be called to get things up and running. So...the problem shouldn't lie in my code at all. PA_GetHTTP simply hangs when it tries to get pages from my host.