Ip address format

Hi Everyone,
One of methods in my COM object is
public void setIP(Variant ip)
with Variant data type supposes to be 4 byte int. I don't know how to convert a string like "192.167.1.108" to an int so I can pass in the above function. Would anybody please help me out!
Thanks in advance
Hung

In java, there is no such thing as an unsigned int. How to put this data into an int is going to depend on how he reads it out. Can you find this out? Does he strictly read each 8 bits as an unsigned byte? If this is the case, the previous examples (mine included) will have problems because signed data types use 2's complement for negative numbers (see http://forum.java.sun.com/thread.jsp?forum=54&thread=143155 ). I've modified the method for this case:
    static int ipToInt(String ip)
     StringTokenizer st = new StringTokenizer(ip, ".");
     int numParts = st.countTokens();
     if (numParts == 0)
          throw new IllegalArgumentException("Invalid IP address: empty argument");
     if (numParts > 4)
          throw new IllegalArgumentException("Invalid IP address: too many tokens");
     long ipLong = 0;
     for (int i = 1; i < numParts; i++)
     /* For all but the last token in an IP address, the nth token corresponds to the
         nth byte from the left (or 4 - n from the right)  */
          String token = st.nextToken();
          int tokenVal = Integer.parseInt(token);
          // Above will throw NumberFormatException if the token is not an integer
          int processedVal = tokenVal << (8 * (4 - i));
          // Moves the byte to the correct portion of the int
          ipLong = ipLong + processedVal;
     /* The right most token of an IP address is always added as its given value
        (never shifted) */
     String token = st.nextToken();
     int tokenVal = Integer.parseInt(token);
     // Above will throw NumberFormatException if the token is not an integer
     ipLong = ipLong + tokenVal;
     if (ipLong > Integer.MAX_VALUE)
     /* This will ensure the proper bits are set using 2's complement when
        converting back to an int */
          ipLong = Integer.MIN_VALUE + (ipLong - Integer.MAX_VALUE - 1);
     int ipInt = new Long(ipLong).intValue();
     return ipInt;
    }If you do the following, you can see each 8 bit section matches:
     String ipString = "192.167.1.108";
     int ipInt = ipToInt(ipString);
     System.out.println("IP:   \t" + ipString);
     System.out.println("ipInt:\t" + ipInt);
     System.out.println("      \t" + Integer.toBinaryString(ipInt)); The results are:
IP:     192.167.1.108
ipInt:  -1062796948
        11000000101001110000000101101100Note the value of this bitwise representation is negative.

Similar Messages

  • My apple id is not working on icloud because it is not in email address format.   how can i change my apple id to email format so icloud can work?

    Hello - I just purchased an iPhone 4s and would like to use iCloud but my apple id is not in email address format so when i try to sign into iCloud it won't let me use my apple id.  i tried to change my apple id through my account settings but could not find a way to do that.  i found ways to change everything else in my settings but when i pushed on the edit button to change my apple id the page didn't change.  Not sure how i can get to use iCloud?  Please help.

    You change the name of your ID at https://appleid.apple.com.  See http://support.apple.com/kb/HE40.

  • How to make Address Book obey Preferences? I run MacBook Pro 4.1 laptop,  Mac OS X 10.6.8  Address Book 5.0.3 (883) Preferences set at ... General First name following Last name   Sort for Last name Address Format Canada Font size Large Phone format set a

    How to make Address Book obey Preferences?
    I run MacBook Pro 4.1 laptop,  Mac OS X 10.6.8
    Address Book 5.0.3 (883) 
    Preferences set at ...
    General
    First name following Last name 
    Sort for Last name
    Address Format Canada
    Font size Large
    Phone format set at
    +1.123.456.7890
    When application quits - it's all forgotten and it self-resets to
    unwanted configuration.

    Whenever you remove system modifications, they must be removed completely, and the only way to do that is to use the uninstallation tool, if any, provided by the third-party developers, or to follow their instructions. If the software has been incompletely removed, you may have to re-download or even reinstall it in order to finish the job.
    Here are some general guidelines. Suppose you want to remove something called “BrickYourMac.” First, consult the product's Help menu, if there is one, for instructions. Finding none there, look on the developer's website, say www.brickyourmac.com. (That may not be the actual name of the site; if necessary, search the Web for the product name.) If you don’t find anything on the website or in your search, email the developer. While you're waiting for a response, download BrickYourMac.dmg and open it. There may be an application in there such as “Uninstall BrickYourMac.” If not, open “BrickYourMac.pkg” and look for an Uninstall button.
    If you can’t remove software in any other way, you’ll have to erase your boot volume and perform a clean reinstallation of OS X. Never install any third-party software unless you're sure you know how to uninstall it; otherwise you may create problems that are very hard to solve.
    Trying to remove complex system modifications by hunting for files by name often will not work and may make the problem worse. The same goes for "utilities" that purport to remove software.

  • How to setup the From header  in fullname and email address format

    when I sent mail from the messaging express , the mail that I sent cannot show the sender in the fullname and email address format. I use webmail and other mail client . It show only email address. I don't know how to setup this . I use the SUN JES messaging server 6.0 SP1 .

    exactly so.
    in general, for any configutil setting:
    0=off=no
    1=yes=on

  • Standard US Address format in Smart forms

    Hi All,
    Can any one please tell me how can we achieve standard US Address format while displaying Address.
    Thanking you in advance.
    Ragards,
    Bhanu.R

    Command ADDRESS - ENDADDRESS formats an address according to the postal standards of the destination country defined in parameter COUNTRY. the reference fields are described in structure ADRC
    Syntax
    /: ADDRESS
    write ur address between this commands
    /: ENDADRRESS

  • Can I set the address format for individual contacts?

    I have some foreign friends and would like to set the address format for their individual cards correctly. I can't seem to find a way to do this. I will be taken aback if this can't be done - I think the old Claris contact product did that.
    Anyone with any answer?
    Bryan

    Hi Bryan,
    When in edit mode, can you right click on the address field and change the country format there? I'm not on a Mac at the moment to double check, but that's what you do in OS 10.4 so I'd be surprised if it were changed in 10.5.
    Edit: Here's picture to demonstrate what I'm referring to:
    !http://www.ampersandbox.com/imprint/change-address-format.jpg!

  • Preventing empty rows in address formats

    Hallo everyone!
    I'd like to know if there is a method to prevent SBO2005A from printing empty rows in the address fields when for instance there is missing county in BP addresses like this:
    I have defined an address format that goes
    Block
    County
    Street
    ZipCode | Freetext(" ") | City
    We use Block as "Name2" and County as "Name3" in master data just in case the customer wants to use additional names for his BPs.
    If I use the "Block" - field and I leave the "County" - field blank it prints an empty row between "Block" and "Street". This is not the behaviour I would like to see. In case "county" is missing I would rather see something like this in a printout:
    Block
    Street
    ZipCode | Freetext(" ") | City
    So, is there a method to force this? or any workaround?

    Hello Patryk,
    PLD does not offer the functionality to control the blank lines in an address field.  I would suggest you use a formatted search in your address field on the marketing document and have it formatted in the document itself before you print.
    Please see sample code for your requirment for the Ship to address.  If you want this to applied to the Bill to address field then you have to slight alter the query by cha
    For Shipto address formatting
    SELECT CASE WHEN T0.Block IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.Block + CHAR(13) + CHAR(10) ELSE '' END +
    CASE WHEN T0.County IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.County + CHAR(13) + CHAR(10) ELSE '' END +
    ISNULL(T0.Street, '') + CHAR(13) + CHAR(10) + ISNULL(T0.ZipCode, '') + '  ' + ISNULL(T0.City, '')
    FROM  [dbo].[CRD1] T0 WHERE T0.AdresType = 'S' AND T0.Address = $[$40.0.0] AND T0.CardCode = $[$4.0.0]
    For Billto address formatting
    SELECT CASE WHEN T0.Block IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.Block + CHAR(13) + CHAR(10) ELSE '' END +
    CASE WHEN T0.County IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.County + CHAR(13) + CHAR(10) ELSE '' END +
    ISNULL(T0.Street, '') + CHAR(13) + CHAR(10) + ISNULL(T0.ZipCode, '') + '  ' + ISNULL(T0.City, '')
    FROM  [dbo].[CRD1] T0 WHERE T0.AdresType = 'B' AND T0.Address = $[$226.0.0] AND T0.CardCode = $[$4.0.0]
    Suda

  • Address Book - Changing the address format?

    A couple of years ago I imported all my old contacts into address book. I've now discovered that I had the address format set to USA in preferences and I'm a UK user. I've since changed the preference to UK but it this only affects new addresses that I add.
    Is there a way to change those old addresses to UK format? I've tried exporting a V card and re-importing but it doesn't change.
    TIA, Steve

    Hi Steve, and a warm welcome to the forums!
    I'd take a look at Barney-15E's Script here for converting to gb/uk...
    http://discussions.apple.com/thread.jspa?threadID=764832

  • Default Address format

    How can i set default address format & show complete name of country & state in pld.

    Hi,
    Check the following thread
    Country Field problem
    Re: Address Formats - Country
    Invoice ship to State and Country
    *Close the thread if issue solved.
    Regards
    Jambulingam.P

  • Script to enforce IP address format

    Greetings,
    In Acrobat XI Pro, in order to ensure the user enters a properly formatted IP address, I have the following JavaScript called from a text field's properties, Format tab using a custom format script.
    // Validate IPv4 address format
    var ipAdr = getField("PHYSICAL IP ADDRESS");
    if (event.value!=null && event.value!="") {
    var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
    if (re.test(ipAdr.value) == false) {
       app.alert("Please enter a valid IPv4 address");
       event.target.setFocus();  
    This appears to be working, though I am wondering:
    (1) Is it ok to not have an else clause?
    (2) Can the RegEx be improved?
    The RegEx is trying to enforce the standard IPv4 dotted decimal notation that does not include the subnet mask.
    Thanks!

    Many thanks Gilad, just one quick one...
    Any thoughts on the 'if' with no 'else'? Or is it just a subjective preference?

  • PRKC-1023 : Invalid IP address format & PRCR-1001 Error in root.sh

    Hello All,
    At prompting to execute root.sh, I get the following errors. I am installating 11.2.0.1 Grid Software. I am not sure why it is taking the virtual IP name.
    The details give are on Specify Cluster configuration window is :-
    Scan name : rs1pre91cl
    Both nodes edited/added as below
    hostname Virtual IP name
    rs1pre91dvdbaa01.pre.ccosvc.com rs1pre91dvdbaa01vip.pre.ccosvc.com
    rs1pre91dvdbaa02.pre.ccosvc.com rs1pre91dvdbaa02vip.pre.ccosvc.com
    Identify network interfaces option used to show eth0 for public (172.) and eth1 for private (192)
    SSH connectivity already established, but tested using this screen.
    Error in root.sh
    PRKC-1023 : Invalid IP address format: rs1pre91dvdba01vip
    add nodeapps -n rs1pre91dvdba01 -A rs1pre91dvdba01vip/255.255.252.0/eth0 on node=rs1pre91dvdba01 ... failed
    PRCR-1001 : Resource ora.net1.network does not exist
    add scan=rs1pre91cl ... failed
    When running pre-checks installation -- it shows me successfull.
    ./runcluvfy.sh stage -pre crsinst -n rs1pre91dvdba01,rs1pre91dvdba02 -fixup -verbose > ~oracle/run_pre_install_cluvfy.out.1
    Has someone experienced this error and what are the steps to fixup
    Thanks

    We have also experienced similar issue with 11.2.0.2 on HPUX:
    srvctl add nodeapps -n host2 -A "host2-vip/255.255.252.0/lan0|lan3"
    PRKC-1023 : Invalid IP address format: host2-vip
    Replacing host2-vip with IP address works fine.
    More surprisingly, on one node, it accepts same command with vip format, whereas on others it is expecting IP address in command. ( although vip names are resolvable to its IP address from all nodes--checked using nslookup)

  • PRCT-1302 : The "OCR," has an invalid IP address format

    Dear RAC experts,
    I am setting up RAC nodes and during installation it fails with error PRCT-1302.
    PRCT-01302: The "{0}" has an invalid IP address format
    Cause: The format of the subnet number and/or the subnet mask is an invalid IP address format. 
    Action: Make sure that both the subnet number and the subnet mask have a valid IP address format.
    It seems like everything OK with subnet. 
    public network
    eth0       
             Mask:255.255.255.192  / 26
    private interconnect
    eth1   Mask:255.255.255.240 / 28
    private interconnect  
    eth2     
            Mask:255.255.255.240 / 28
    Please advice.
    Thanks in advance.
    RAC 2node
    Linux
    VMware
    IBM

    Hey ioannis,
    So I would recommend starting from scratch on this one and seeing if we can get things to work.  I would recommend following these steps:
    Make sure that you have access to port 80, which is what LabVIEW and the Web Server uses for communication.  This might mean turning off virus checkers or firewalls, as Altenbach suggested.
    Restart your computer.  This is to make sure that there isn't anything already accessing this port that is conflicting.
    Start LabVIEW once the computer is back up.
    Open the VI that you would like to publish.  I might recommend using an Example just to test, but you could use your program.
    Select Tools » Web Publishing Tool (WPT).
    On the bottom of the WPT window, press the Start Web Server button.
    Configure your VI as you would like.  You can probably just use the defaults for now. 
    Select Save to Disk and replace the file if necessary.
    Hightlight the address that comes up in the Document URL window and press Ctrl+C to copy it.
    Open Internet Explorer and past the URL into the address bar on the development computer. 
    These steps should be all that is necessary to use the WPT, so please follow them and let me know if they help or not. 
    Thanks!
    Andy F.
    Message Edited by Andy F. on 03-17-2006 12:41 PM
    National Instruments

  • Address Format Help Needed

    Could someone please direct me to some information explaining how Apple deals with Address Formats?
    I upgraded to Snow Leopard, then synced. I was syncing from what a perfect version which I had saved on Mobileme before upgrading, and I had not changed anything on the computer after upgrading. I expected it to be straightforward. However, I was told that I had 730 conflicts in Address Book. (That's half my records). When I started to go through these conflicts, I found that they all had something to do with Address Formats. One version, for example, had format 'Japan', and was formatted one way, and another version, had format 'ja', and was formatted another way. Also, sometimes I had 'United Kingdom', and sometimes 'uk'. Actually, there were all sorts of strange conflicts, which is why I'd appreciate some general information that I can study.

    Using 'Reset Sync Data', I uploaded a perfect version of my contacts from an ibook running 10.4.11. It was when I tried to download this onto another, new, computer using 10.6 (again using 'Reset Sync Data' that all these conflicts came up. There was nothing on the latter machine for there to be a conflict with.
    Thanks for your advice, but if I always choose the side with the full name, then I will be sometimes choosing a side that has an incorrectly written address. And I'm afraid I don't want to have to spend a morning doing this 730 times, as very often I also need to check the address from the original computer.
    What I'd like to know is if there is a way to do this without these conflicts. I suppose I could just copy/paste the address data, but then next time I sync, will I get the conflicts again? Why is this happening? What are these two letter codes?

  • JAAS -Incorrect address format-Heimdal

    hello,
    I am trying to execute the jaas authentication tutorial sited in the following url: " http://java.sun.com/j2se/1.4.2/docs/guide/security/jgss/tutorials/AcnOnly.html ". But when I set the "useTicketCache" option to true in the jaas.conf configuration file and run the code it returns the error:
    "Incorrect address format."
    Authentication failed:
    java.lang.OutOfMemoryError
    I also add the option: 'ticketCache="/tmp/krb5cc_0"' but the error remains.
    Before running the code of the tutorial, I have executed heimdal's kinit so the TGT of the principal is placed in the ticketCache, in the "/tmp/krb5cc_0" file.
    The version of kerberos I am using is 'heimdal daily snapshot october 2005'.
    Does anyone have a clue why this fault occurs?
    Thanks in advance!

    On 15.05.2012 23:26, dsag wrote:
    >
    > I have been having the following issue. A internal GW users sends an
    > email to a external non-groupwise user and cc's other internal groupwise
    > users. The external non-groupwise user replies to the email, then
    > receives several bounce messages because some of the users do not exist.
    > When looking at the header I see that some of the internal users email
    > address are in the userid.po.dom format, while others are in the
    > userid.domain format. It has only been happening for the past couple of
    > months. What have I changed to create this issue? Thanks. David
    Check the personal addressbooks of the sender. Most likely he has the
    wrong internal users in his AB incorrectly.
    CU,
    Massimo Rosen
    Novell Knowledge Partner
    No emails please!
    http://www.cfc-it.de

  • CRM Internet Sales User - address format

    Hi !
    In the CRM 4.0 Internet Sales application, when 'register.jsp' is triggered to register a new internet user, the default address format always seems to pick the US addressFormular (Zipcode field instead of Postalcode). Would anyone have an idea what change has to be made to pick the correct addressFormular to get the correct  address format ?
    Regards,
    Ashok.

    Thanks, Ashok. I will try to get login info.
    I just noticed that in inputaddressformat_us.inc, the following portion of the code inside the iterate tag is not getting executed.
    <isa:iterate id="country" name="<%= B2cConstants.POSSIBLE_COUNTRIES %>" type= "com.sapmarkets.isa.core.util.table.ResultData" resetCursor="true">
              <% // Should the current country be marked as selected?
                 String selected="";
                 if  (country.getString("ID").equals(defaultCountryId)) {
                     selected="SELECTED";
                 } %>
                 <OPTION VALUE="<%= country.getString("ID") %>" <%= selected %>>
                   <%= country.getString("DESCRIPTION") %>
                 </OPTION>
            </isa:iterate>
    I think that is the reason. But why it is not executing that code?
    Do you have an idea about it?
    Thanks,
    Harsha

  • Address formating in Script

    Hi,
    I wanted to know How the control will format the address of particular customer between ADDRESS...ENDADDRESS command.
    I wanted to know where the ADDRESS format is maintained for different countries.
    Pls let me know asap.

    Hi,
    The table is T005, field ADDRS.  The meaning of this code is held in T005A.
    Regards,
    Nick

Maybe you are looking for

  • Open box Item not as described.

    I recently ordered an Open Box Pioneer Elite SC-81 . As per description the condition was described as Excellent condition on Best buy website.  Receiver has Scratches on the Volume Knob as well as dent on the top. Excellent product conditions are no

  • Nokia n8 update no Notifications Widget

    I have upgraded my n8-00 to newest belle and i am not finding Notifications widget any more, i liked to have it on my homescreen to see when who called, how many sms have i not read and etc. Is there a way to restore this widget? as it is very useful

  • [solved] CUPS a nd HPLIP issues

    I have this old Pentium II machine running LXbuntu 9.04. Everything is working fine on it, except it cannot be upgraded without breaking everything because it is ubuntu. Also, the CUPS/HPLIP combo is working fine on it and my USB-connected printer is

  • How can pass the data from Command line  to  Applet?

    Hi, I am writing a chat application by using sockets. For that purpose I need to pass the parameter data from command line to Applets. Is there any method to receive command line args data in Applets? If so please tell me.

  • Monitoring stock at Third-party Manufacturers

    Hi, We provide our third-party manufacturers with stock such as packaging. As such we keep stock at their warehouses as well as some safety stock at our own warehouses. However we are finding it difficult to keep track of their use of our packaging m