Results 1 to 2 of 2

Thread: weirdness

  1. #1

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919

    weirdness

    Okay,
    I got ICMP to work. But heres the problem.

    It doesnt work

    I use the "GetLastError()" function, and I get error # 122, which i looked up
    I think its 'bad address'

    I checked my IP checking function, and i printed out what it returns. It looks fine.

    Hostname www.vbworld.com resolved to 161.58.186.98
    1656371873
    Error: 122
    Press any key to continue
    now i think technically, if you enter the "1656371873" address into your browser, it'll bring you to VBWorld. It doesn't

    My IP checking function is below that, and below that is the ICMP stuff.

    Yahoo! comes out as a negative number.

    Thanks guys
    -nabeel

    PHP Code:
    u_long WSOCK::checkIP(char *IP){
        
    u_long iaIP;

        
    iaIP=inet_addr(IP);
        if (
    iaIP==INADDR_NONE) {
    //        iaIP=0;
            
    HOSTENThst=NULL;
            
    hst gethostbyname(IP);    

            
    struct in_addr ia
            
    //attempt to resolve the hostname
            
    hst gethostbyname(IP);    

            
    //check for valid hostname
            
    if(hst == NULL){
                
    printf("An invalid hostname was entered, or hostname not found\n");
                return -
    1;
            }

            
    char *ipAdd = new char[15];
            
    // Format it into a string
            
    for(int i=0;hst->h_addr_list[i];i++){
                
    memcpy(&ia.s_addr,hst->h_addr_list[i],sizeof(ia.s_addr));
                
    ipAdd=(char *) inet_ntoa(ia);
            }
            
            
    printf ("Hostname %s resolved to %s\n",IP,ipAdd);
            
    iaIP inet_addr(ipAdd);
        
            
    //check whether its also a null ip
            
    if(iaIP == INADDR_NONE){
                
    printf("Hostname/IP not found\n");
                return -
    1;
            }
        }        
        return 
    iaIP;

    PHP Code:
        if(!ini)
            return -
    2//return -2 for no wsock initialization

        //check the IP Address
        
    u_long ipaddress;
        if((
    ipaddressWSOCK::checkIP(IPorHost)) == -1){
            
    printf("IP Address Error\n");
            return -
    1;
        }

        
    printf("%d\n",ipaddress);

        
    char tmp[32];
        for (
    int i=0;i<32;i++)
            
    tmp[i]=' ';


        
    HANDLE hFile;
        
    hFile IcmpCreateFile();

        
    //finish it up
        
    ip_option_information *optinfo= new ip_option_information;
        
    icmp_echo_reply *echo = new icmp_echo_reply;

        
    optinfo->Ttl ttl//set time to live
        
    int retval=-1;
        if((
    IcmpSendEcho(hFile,(IPAddr)ipaddress,tmp,strlen(tmp),optinfo,echo,sizeof(echo)+8,2000)))
            
    retval = echo->RoundTripTime;
        else 
            
    retval = -1;

        
    IcmpCloseHandle(hFile);
        return 
    retval
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  2. #2

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    no suggestions?
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width