Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-20-2007, 07:51 AM   #1 (permalink)
muhaa
Recruit
 
Join Date: Mar 2007
Posts: 3
muhaa is on a distinguished road
loop help

Hi all i was wondering if any one could help me i have a program i made using wininet in c c++ and my program is not seeing if there is a connections before completing with the execution ive tried to get it sorted but cant seam to figure it out i was guna use a loop and just make the program start over and over again till it finds a connection here is what ive got so far any help would be much apriciated.
Here is what ive got so far im verry new to c c++ but im trying to learn some stuff the program uploads to our ftp server a jpg file of screen shot from punk buster.I had to add it to the reg just incase we need to reboot our game server.This is what i have so far.

PHP Code:
#include <stdio.h>

#include <wininet.h>



#define server "test"

#define user "test"

#define pass "test"





int Upload(char *localFilechar *remoteFile){

HINTERNET iSession;

HINTERNET iConnect;

    

iSession InternetOpen("Explorer" INTERNET_OPEN_TYPE_DIRECTNULLNULL0);

iConnect InternetConnect iSessionserverINTERNET_DEFAULT_FTP_PORTuserpassINTERNET_SERVICE_FTP00);

    

if(
TRUE==FtpPutFileiConnectlocalFileremoteFileFTP_TRANSFER_TYPE_BINARY0))



    
printf("Success");//I need this to just carry on exe



    
else printf("Error!");//Im trying to get this to loop till conection is found

    

    

InternetCloseHandle(iConnect);

InternetCloseHandle(iSession);



return 
0;

}



int main(void)

{   

    

Upload("C:\\1.jpg","1.jpg");



char system[MAX_PATH];

char pathtofile[MAX_PATH];

HMODULE GetModH GetModuleHandle(NULL);



GetModuleFileName(GetModH,pathtofile,sizeof(pathtofile));

GetSystemDirectory(system,sizeof(system));



strcat(system,"\\test.exe");



CopyFile(pathtofile,system,false);





HKEY hKey;



RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_SET_VALUE,&hKey );



RegSetValueEx(hKey"Writing to the Registry Example",0,REG_SZ,(const unsigned char*)system,sizeof(system));



RegCloseKey(hKey); 



 return 
0;


muhaa is offline   Reply With Quote
Old 03-20-2007, 03:06 PM   #2 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 681
DJMaze is on a distinguished road
You want something like
Code:
while (not_connected)
{
    try
    {
    }
    catch (...)
    {
    }
}
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 03-20-2007, 05:21 PM   #3 (permalink)
muhaa
Recruit
 
Join Date: Mar 2007
Posts: 3
muhaa is on a distinguished road
Ok m8 but could you explain to me what it does and how i implament it into my code thnx for your time.Im verry new to c c ++ but know perl python and a few others like php and action script..But im newbie with c c ++.
muhaa is offline   Reply With Quote
Old 03-20-2007, 09:54 PM   #4 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Seems like if it had a problem connecting, you should a least wait a short while (sleep) before trying to connect again, to give transient network problems a chance to clear up.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 03-21-2007, 04:47 AM   #5 (permalink)
muhaa
Recruit
 
Join Date: Mar 2007
Posts: 3
muhaa is on a distinguished road
Yeh m8 its like my router takes a while before it actualy connects to the net maybe like 60 seconds after start up maybe i can halt the execution of my program for 2 minute at the start of the program any one know haw i looked into sys pause but was told not to use it by some other people im just looking for some to slow my prgram down..
muhaa is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy (for you ninjas) loop question draven77 PHP 9 02-16-2006 10:48 PM
Can't get loop to work rockybalboa Java 5 03-20-2005 03:54 PM
do-while loop M3GAPL3X Standard C, C++ 4 06-26-2003 09:57 PM
Breaking out of external loop agh Standard C, C++ 7 04-30-2003 08:03 PM
the endless loop loop loop loop loop loop ... abc123 All Other Coding Languages 2 08-14-2002 03:43 PM


All times are GMT -8. The time now is 06:37 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting