SLPBoolean MySLPSrvURLCallback(SLPHandle hslp, const char * srvurl,
                               unsigned short lifetime, SLPError errcode, void * cookie)
{
    (void)hslp;
    switch (errcode)
    {
        case SLP_OK:
            SLPSrvURL	*parsedurl;
            SLPError err = SLPParseSrvURL(srvurl, &parsedurl); 
            if ( err == 0) 
            {
                printf("Service Type = %s\n", parsedurl->s_pcSrvType);
                printf("Host Identification = %s\n", parsedurl->s_pcHost);
                printf("Port Number = %d\n", parsedurl->s_iPort);
                printf("Family = %s\n", ((strlen(parsedurl->s_pcNetFamily)==0)?"IP":"Other"));
                printf("URL Remainder = %s\n", parsedurl->s_pcSrvPart);
            } else
            {
                NSLog(@"Error parsing SrvURL");
            }
            *(SLPError *)cookie = SLP_OK;
            
            break;
            
        case SLP_LAST_CALL:
            printf("**********************************************");
            printf("MySLPSrvURLCallback Error Code is  = %d\n", errcode);
            printf("**********************************************");
            break;
            
        default:
            *(SLPError *)cookie = errcode;
            break;
    }
    return SLP_TRUE;
}

void findSLPServicesInLAN()
{
    SLPError err;
    SLPError callbackerr;
    SLPHandle hslp;

   err = SLPOpen("en", SLP_FALSE, &hslp);

    if(err == SLP_OK)
    {

        err = SLPFindSrvs(hslp, [serviceName UTF8String], 0, 0,
                          MySLPSrvURLCallback, &callbackerr);
        if(err != SLP_OK)
        {
            NSLog(@"Error registering service with slp. %d",err);
        }
        /* Now that we're done using slp, close the slp handle */
        SLPClose(hslp);
    }
    else
    {
        NSLog(@"Error opening slp handle. %d",err);
    }
}