Getting IP Address information from an NSNetService object

I have an NSNetService object that I received from doing a Bonjour discovery. This object represents a web server that I want to connect to.
I have the following (nasty) code for doing that:
- (void) serviceReceived:(BonjourViewController*)bvc didResolveInstance:(NSNetService*)ref;
if (ref == nil) {
// The resolve was cancelled.
return;
NSArray* addressArray = [ref addresses];
if ([addressArray count] == 0) {
return;
NSData* address = [addressArray objectAtIndex:0];
void* buffer[[address length]];
[address getBytes:buffer];
int ipAddress = (int) buffer[1];
int classA = ipAddress & 0x000000FF;
int classB = (ipAddress & 0x0000FF00) >> 8;
int classC = (ipAddress & 0x00FF0000) >> 16;
int classD = (ipAddress & 0xFF000000) >> 24;
int port = [ref port];
NSString* hostName = [NSString stringWithFormat:@"%d.%d.%d.%d:%d", classA, classB, classC, classD, port];
NSURL* url = [[NSURL alloc] initWithScheme:@"http" host:hostName path:@"/index.html"];
I can't just use the hostname because it's not a valid DNS entry, and the Bonjour name doesn't work with most of the libraries like:
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:URL];
Oddly enough, Safari is perfectly happy with the Bonjour name "compname.local.".
There must be a better way of getting an NSString with the dotted-quad than getting the bytes and manually picking apart the IP address from them. This code breaks as soon as we all move to IPv6.
Any help would be appreciated,
-Chris.
Message was edited by: clevans
Message was edited by: clevans

Use an application bean if you want to keep a list of
all the users stored on a server.
When someone logs on, grab the ip, login name, and
password. Store this in the application scope bean.
Every time a page is accessed, check the ip to see if
it has been previously stored in the bean. If so,
load the login and password and use them for logging
in to the page. If not, include another preset login
page, or lik to it with the previous page stored in a
session scope bean.
The ips, login names, and passwords should be enclosed
in a class (simple one with three fields). When
someone logs on, create a new instance and send it to
the application scope bean, where it should be stored
in a java.util.HashMap (my favorite kind, and really
quick).
There should also be a way to time-out the user after
a while of not connecting - removing their ip from the
application scope bean. Very important if you want
security.
That's all I can think of for now.
Spaceman40Close enough, however I will point out that you don't need to store the password. I am also confused why you are saying an application level bean. This needs to be a bean that can be accessed by all of our applications. If one application creates the bean all of them should be able to see it.
I was thinking of doing this: Each application gets a session bean that looks for an entity bean with the primary key of the client's IP address. If the bean is there it gets the user ID from that and logs that user into the system. If the bean isn't there, it fires off a login procedure for the client to enter their username and password. If the login is successful it creates the bean. The session bean stays around until the user logs out of the system. The last session bean linked to that entity bean destroys it.
Has anyone seen this before? Is there a design pattern for a last one out turn off the light in EJB?

Similar Messages

  • How can I get anyones address book from ecxhange and show them to user

    I am trying to get someones adressbook information from MS exchange for caller to be able to make call from IP Phone interface. Is there any rapid solution.

    First you must import them to your computer, and then sync your iPhone to your computer.
    http://www.juliakm.com/transferring-aol-address-book-apple039s-address-book
    http://email.about.com/od/windowslivehotmailtips/qt/Export_Contacts_Email_Addres ses_from_Windows_Live_Hotmail.htm

  • Need to pull vendor address information from PO

    Hi Friends..
    I am creating a shipper instructions smartform and need to display shippers address in the form.. For that purpose i need to pull the vendor address information from the PO...
    Can some one tell me the data extraction logic involved here like what tables i need to access to get the required vendor address and flow of it...
    Here the client is creating the PO and also sending the shippers instruction form when PO is created as far as i my understanding...
    Thanks,
    Kanthi..

    Hi
    When a PO is created, at that time you need to enter vendor number (LIFNR).
    The details of different vendors are maintained in table LFA1.
    The tables for PO are EKKO (header table) and EKPO (line item table).
    But, if you want to capture the vendor address for printing, you only need to know the PO number (EBELN field). And, then you can proceed like:
    Select LIFNR from EKKO into <yourDefinedVAR> where EBELN = XYZ.
    Select <requiredAddressFields> from LFA1 into (....) where LIFNR = <yourDefinedVAR>.
    So, finally, if you know the PO number, you can find rest of the things.
    Regards
    Ashish

  • I need to get the cluster information using"MSCluster.Cluster" object

    Hi,
    Please anyone solve my problem ? I need to get the cluster information using"MSCluster.Cluster" object.
    Set objCluster = CreateObject("MSCluster.Cluster")
    objCluster .open <clustername>
    If i run the vbscript " Microsoft VBScript runtime error: ActiveX component can't create object: 'MSCluster.Cluster' " error is thrown.
    Kindly explain what is the issue and what can i do ? 
    -Sundar.

    this question was closed and answered a long time ago.
    Post questions about WS2012 in th WS2012 forum.
    The cluster object will no longer work in WS2012.  Use the supplied CmdLets and utilities.
    post future questions in the WS2012 forum.
    ¯\_(ツ)_/¯

  • How can I get CDP neighbor information from access point reports in Cisco Prime 2.0

    How can I get CDP neighbor information from access point reports in Cisco Prime 2.0?  I have looked through all the reports and I cannot find a report that gives me the CDP neighbor information of an access point.  I thought that information was in there, however I cannot seem to find it.
    Thanks in advance!

    Hi
    You can get this from an inventory report in PI (Select Report Type AP). Here is an example of PI 2.1 works for me. Once you export this into excel you can sort based on controllers & filter the single controller connected AP you want.
    Regards
    Rasika
    **** Pls rate all useful responses ****

  • How to get RMAN catalog information from Target database?

    Hi,
    How to get RMAN catalog information from Target database because i don't know about catalog database? is it possible?
    Thanks

    If you run RMAN backups of a target database using a Catalog schema in another database, the target is not aware of the catalog.
    The RMAN backup script would have the connection identifier for the Catalog.
    Hemant K Chitale

  • FM to get work center information from routing

    Hi all,
    Is there any FM to get work center information from routing?
    Points assured.
    Thanks and regards,
    Nilesh

    Use This FM
    CR_WORKSTATION_READ_ROUTING,ROUTING_DISPLAY
    Use table CRHD ,MAPL
    Please reward if useful.

  • Received new mac how do you get all your information from old mac?

    Received a new mac for my daughter.  How do you get all the information from old mac?

    Your best bet, by far, is to use Setup Assistant when your shiny new Mac first starts up (not Migration Assistant later).
    See How do I set up a new Mac from my old Mac or its backups?

  • Remote Desktop Virtualization Host failed to get redirection authentication information from the virtual machine

    Hello,
    When implementing a VDI solution, I'm getting an error on our virtualization host server.  The error is:
    Remote Desktop Virtualization Host failed to get redirection authentication information from the virtual machine [VDI-PC].
    Hresult 0x8000FFFF
    Event ID 8467, Severity: Warning, Source: Microsoft-Windows-TerminalServices\TSV\VmHostAgent
    This error happens every time a user or admin connects to a VDI desktop.  This is a fresh install of Remote Desktop Services on completely fresh servers.  This is in testing and we have not ever had it working before without the error.
    Topolgy: Server2012 R2, Windows 7
    Srv-RDCB1: Is the connection broker and Web Access server.  It is Virtualized thru Hyper=V.
    Srv-RDVH1: Is the virtualization host.  It is a physical server. It also has a separated hyper-v role (for RDS VDI deployment).
    Everything seems to be functional other than this error in the log, and I haven't found any information on what this could mean.
    Any help is greatly appreciated, thanks!

    Hello. I have this trouble too.
    All roles on one server.
    Deployment type - Quick start
    Deployment Scenario Virtual mashine-based desktop deplyment
    Reinstall all roles 2 times
    Warning TerminalServices-TSV-VmHostAgent
    8467 Orchestration
    Remote Desktop Virtualization Host failed to get redirection authentication information from the virtual machine [per-0] . 
    Hresult: 0x8000FFFF
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    <System>
      <Provider Name="Microsoft-Windows-TerminalServices-TSV-VmHostAgent" Guid="{92618A87-2F6A-4B75-9AE2-E77BE7EAF43C}"
    />
      <EventID>8467</EventID>
      <Version>0</Version>
      <Level>3</Level>
      <Task>22</Task>
      <Opcode>14</Opcode>
      <Keywords>0x4000000000000000</Keywords>
      <TimeCreated
    SystemTime="2014-11-11T13:24:45.579138000Z" />
      <EventRecordID>1655</EventRecordID>
      <Correlation
    ActivityID="{F4200EF7-FEDD-4CAD-9F5D-6219A5F30000}" />
      <Execution ProcessID="3164" ThreadID="13164" />
      <Channel>Microsoft-Windows-TerminalServices-TSV-VmHostAgent/Operational</Channel>
      <Computer>blade2.vzfei.local</Computer>
      <Security UserID="S-1-5-20" />
      </System>
    <UserData>
    <EventXML xmlns="Event_NS">
      <param1>per-0</param1>
      <param2>0x8000ffff</param2>
      </EventXML>
      </UserData>
     </Event>
    In RD Gateway Manager, right-click on the RD RAP and click Properties.  On Network Resources tab select
    “Allow users to connect to any network resource”.
    not work.

  • Getting the Address Information based on the Partner Number & Partner Role

    Hello,
             I have a requirement where in I am populating the Address into a Custom Segment Z1E1ADRM1 where I am reading the Partner Data from E1ADRM1 Segment. It has the PARTNER_Q which contains the Partner Role (WE,AG,RE,RG etc...) and PARTNER_ID which contains the Partner Number. Now, using VBPA Table, I am populating the STREET4 and STREET5 manually by passing the Address Number got from VBPA Read.
            Instead, is there any Function Module / BAPI which can be used to get the Address Number / Address Information based on the Partner Role and Partner Number as Input Parameters? Please Let me know.
    Thanks and Regards,
    Venkat Phani Prasad Konduri

    Try
    /SPE/BUPA                      SPE Business Partners             
    /SPE/BP_STORE_ADDRESSES        Business partners store addresses 
    BPAR_P_PARTNERS_WITH_ADDRESS                                     
    SD_ADDRESS_KEY_GET_FROM_VBPA                                               
    SD_ADDRESS_TYPE_GET                                                        
    SD_PARTNER_ADDR_DIALOG_INTERN                                              
    VELO01_GET_PART_ADDR_FOR_VBELN   get the partners and their address details
    WS_LM_ADDRESS_READ                                                         
    WS_LM_CONTACT_ADDRESS_DISPLAY                                                                               
    ^Saquib

  • Capturing information from the Resource Object forms

    Hello,
    I'd like to capture information (dburl, dbdriver,username and password) from my resource objects to use in a class i'm developing through the API.
    However, I failed to find any methods in API to get this information... does anyone know how to retrieve this?
    Thanks in advance,
    Tomic

    Hi,
    I am not very clear about your question.The information below is usually store in IT Resource.If these information is store in IT Resource you can use tcITResourceInstanceOperationsIntf.
    What is your business drive for getting this information from resource object form.Can you explain me so that I can have better answer.
    Regards
    Nitesh

  • I am having trouble trying to get my address book from my mac (just downloaded Lion for this purpose) to my 3G ipad. Set up an icloud account but still confused! Please help !

    I updated my mac with  os x Lion so that I could accomplish moving my address book from the mac to my new IPad 3G. I also set up an icloud account for this purpose, but I *still* cannot figure out how to move my address book from one computer to the other. When I'm on my mac and try to use bluetooth to export the address book, I'm able to find my ipad but I soon get a message that it does not support the necessary services. I have no idea what's going on and would appreciate any advice. tks in advance, Sarah

    blacksheepfibers wrote:
    I updated my mac with  os x Lion so that I could accomplish moving my address book from the mac to my new IPad 3G. I also set up an icloud account for this purpose, but I *still* cannot figure out how to move my address book from one computer to the other. When I'm on my mac and try to use bluetooth to export the address book, I'm able to find my ipad but I soon get a message that it does not support the necessary services. I have no idea what's going on and would appreciate any advice. tks in advance, Sarah
    The address book syncs via iCloud, not Bluetooth or iTunes.
    You upgraded to Lion so you could use iCoud.
    On the computer. go to Apple menu > System prefs > iCloud.
    Sign into your iCloud account.
    Tick everything.
    This enalbes the se items syncing to iCloud.
    On the iPad, Settings > Mail, Contacts, Calendars.
    Create a new iCloud account.
    Sign in with the same AppleID as your computer.
    Settings > iCloud and turn everything on.
    BAM!
    That is all you need to do.
    Your contacts (and all other checked items checked) will sync between computer and iPad.
    No need to use iTunes

  • IPhone SDK: UIWebView - How to get the anchor information from  URLRequs

    I was planning to use the UIWebView but i am stumped now.
    When the user clicks on a hyperlink, the web view delegate shouldStartLoadWithRequest is called and it does not contain the anchor information.
    For e.g. if the href is say #01_02. This to a normal browser is a local anchor. The URL in the NSURLRequest contains just the file name information not the anchor.
    In my particular case a anchor can be some other view of the topic which i will generate and keep it ready for the browser at this point. But since i don't get the anchor information it just shows the current page.
    Is there a way to get the original value encoded in the HREF?
    Thanks in advance,
    -TRS

    I may not have understood your question but if you want to pull out the anchor information out of a request, have you tried the fragment property of the NSURL object?
    // request is type (NSURLRequest *); within shouldStartLoadWithRequest
    NSString *fragment = \[\[request URL\] fragment\];
    Usually this will have the anchor without the #, in your case 01_02.

  • Hi, Just got a new mac, how do I get may address/contacts from old computer to "mail' on new computer

    How do i get my address/contact list from entourage on old mac, to 'mail' on new mac?

    Peruse Pondini's Setup New Mac guide and consider starting over, using the Setup Assistant to do the migration.

  • I just pressed the wrong button to erase of my IMac, how can I get back all information from my computer ?

    I just pressed the wrong button to erase of my iMac, how can i get back all information ?

    Possibly through a data rescue service (can cost a four-figure amount) if you didn't have an external backup.
    But you must stop using that Mac immediately, or your data will be over-written.

Maybe you are looking for