Acquiring local address for datagram socket created by DatagramChannel.open

I've found that when I open an anonymous DatagramChannel (i.e. unbound, unconnected), the socket that it creates has no local address info I.e. no local port. Hopefully the example below will explain the problem...
import java.nio.channels.DatagramChannel;
import java.io.IOException;
import java.net.DatagramSocket;
import java.net.DatagramPacket;
import java.net.InetAddress;
public class QuickTest {
    public static void main( String[] args )    {
        try {
            DatagramChannel dc = DatagramChannel.open();
            DatagramSocket ds = dc.socket();
            byte[] ba = new byte[]{0,1,2,3};
            DatagramPacket dp = new DatagramPacket(ba,4,InetAddress.getLocalHost(),8000);
            ds.send(dp);
            System.out.println( "DatagramSocket from DatagramChannel");
            System.out.println();
            System.out.println( "          getInetAddress(): " + ds.getInetAddress());
            System.out.println( "         getLocalAddress(): " + ds.getLocalAddress ());
            System.out.println( "            getLocalPort(): " + ds.getLocalPort());
            System.out.println( "   getLocalSocketAddress(): " + ds.getLocalSocketAddress());
            System.out.println( "                 getPort(): " + ds.getPort());
            System.out.println( "  getRemoteSocketAddress(): " + ds.getRemoteSocketAddress());
            ds = new DatagramSocket();
            System.out.println();
            System.out.println();
            System.out.println();
            System.out.println( "DatagramSocket from new DatagramSocket()");
            System.out.println();
            System.out.println( "          getInetAddress(): " + ds.getInetAddress());
            System.out.println( "         getLocalAddress(): " + ds.getLocalAddress ());
            System.out.println( "            getLocalPort(): " + ds.getLocalPort());
            System.out.println( "   getLocalSocketAddress(): "    + ds.getLocalSocketAddress());
            System.out.println( "                 getPort(): " + ds.getPort());
            System.out.println( "  getRemoteSocketAddress(): " + ds.getRemoteSocketAddress());
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
}Running this program yields the following information....
DatagramSocket from DatagramChannel
getInetAddress(): null
getLocalAddress(): 0.0.0.0/0.0.0.0
getLocalPort(): 0
getLocalSocketAddress(): 0.0.0.0/0.0.0.0:0
getPort(): -1
getRemoteSocketAddress(): null
DatagramSocket from new DatagramSocket()
getInetAddress(): null
getLocalAddress(): 0.0.0.0/0.0.0.0
getLocalPort(): 1194
getLocalSocketAddress(): 0.0.0.0/0.0.0.0:1194
getPort(): -1
getRemoteSocketAddress(): null
I understand that the sockets address will be included in any packets sent, but why can I determine the port for one and not the other? I would like to continue using an anonymous channel, but I also would like to have the port for use in my test harness and for logging info...
Any info and possible work around for this behavior would be much appreciated.
tx in advance.

This looks like a bug in the socket returned by DatagramSocketChannel and you should report it.
In the meantime you could either just use DatagramSocket, or if you must have NIO you could try binding this socket to null or new InetSocketAddress(null,0) and see whether getLocalPort() now returns the right data.

Similar Messages

  • SG300 cant change the Link Local address for an IPv6 interface

    There seems to be no apparent way to change the Link Local address for an IPv6 interface
    If I create more than one interface they all appear to have the same Link Local address

    Never mind, I figured it out
    By adding a Link Local address to an interface, it overides the existing one on the interface

  • Why use link-local addressing for HSRP in IPv6?

    I have scoured the internet for an answer to this question, and am no closer to having it answered.  Am hoping someone here can help!
    * Why do we use link-local (or autoconfig) addresses for the standby IP in FHRPs?  If you are forwarding a packet towards a link-local destination address, wouldn't the source address then have to be a link-local address from the same prefix, which according to scope, should not route beyond the local link?  How do you route an IP packet that has a link-local address for a source address?
    Any insight would be much appreciated.
    Thank you in advance.

    Dougles,
    next hop is used for reaching "gateway" that know where to send packets farther (read it as "next hop to the destination")... routing in IPvX is hopping between nodes where every hop is closer to destination... This is theory behind.
    So as machine that needs to send packet to "not directly connected destination" you only need to send packet to gateway leading to this destination...
    so you need to send packet so, that "gateway" will recieve this packet and gateway then send this packet farther... it is not important what IP address this gateway has.
    On ethernet you only need to know MAC address of this gateway and you send packet (with your source IPv6 address and intended destination IPv6 address) encapsulated with "destination MAC address" of gateway. When gateway recieve ethernet frame, and this frame is for it (destination MAC address is its MAC address), the gateway will proceed IP header (inside IP header the gateway see IT is not final destination for this packet, and gateway will route this packet).
    So configuring IP address as next hop is just "hleper for simpler administration".. MAC address of gateway is important. In IPv4 address resolution protocol (ARP) is used to automaticly get MAC address of gateway if you configure next hop as IP address. In IPv6 there is neighbor discovery protocol(ND) used for this task.
    conclusion: you can use link local address as nex hop address for addresses from any scope ... next hop is just next hop, it is not used just for the same scope communication.
    And question is... if we need just information about MAC address of gateway, why to ask using global address?
    We need to get MAC address... that is information important just "locally"... so to ask for local information, why not use link local address ?
    HSRP is the same case... really just need MAC address to send packets correctly.

  • Local Authentication for Guest accounts created on WCS

    I'm not sure this is technically possible but I have a requirement to set up an SSID on a WLC whereby I can provision guest user accounts from the WCS and have the WLC / SSID authenticate against the guest account created on the WCS. The SSID would not be a web-auth / layer 3 auth model but preferably be able to utilise layer 2 authentication (802.1x) against the account within WCS. Can anyone tell me if this is actually possible?
    Thanks in advance for your help.
    Cheers
    Sent from Cisco Technical Support iPad App

    Ok then .. Sounds like you are already very fimilar with the wlc..
    Lets kick a few ideas around ..
    If you want to use WCS lobby then you cant use radius, becuase WCS will not update radius accounts. But you could use the WLC as a radius server and store the guest account(s) on the WLC. Gives you 802.1X security, WCS loddy admin access and your guest accounts. You can also expire the accounts as well. So you would move the control from radius to the wlc. You can also apply your qos / bandwidth.
    Another option would be to create radius accounts. Set up your guest wlan, point it to radius. You can still apply a global bandwith restriction within the qos profile on the wlc.
    "Satisfaction does not come from knowing the solution, it comes from knowing why." - Rosalind Franklin
    ‎"I'm in a serious relationship with my Wi-Fi. You could say we have a connection."

  • Exchange setup via local address

    Hi Folks
    Am trying to setup an iPad2 so that it connects to our exchange server locally via wifi. am trying to avoid it using proxy and external sites.
    Has anyone managed to set one up this way as im struggling to get the exchange account setup to work. I can use safari and connect to the local address fine though which is odd?
    thanks

    Thanks for the reply
    Its a wifi only model and its connecting to my windows 2008 r2 domain wireless network, we want to avoid using the proxy and letting the user have access to the web. Hence why were trying to configure it to use the local address for our exchange server. As i previously said, that address works via safari yet the mail exchange setup doesnt accept it.
    cheers

  • How to configure IP address for FTA (Nova's nFusion) PVR IP recording...

    Greetings Peers,
    I just got my Time Capsule (TC) yesterday and absolutely have very limited experience with Airport Utility or networking - that said I somehow figured out how to setup a new secured wireless network and it is up & running!
    I'm testing this absolute great Free-to-Air (FTA) satellite receiver called *Nova nFusion* where there is a functionality option to record your personal video (PVR) on a IP address.
    Here's my dilemma, I have tried punching in IP address from what AirPort Utility (AU) displays for Time Capsule (TC) several times but receiver *would fail* to record anything!
    I have tried to tweak general settings like enabling sharing in the manual setup for TC under AU but like I said I'm not an expert and it didn't work.
    Wondering:
    1) If anyone has success setting up similar PVR over IP?
    2) Is this even feasible? Honestly, I don't see why not? Cause I'm also planning to have move my iTunes library folder on TC so I could access it from my Mac Mini, iBook, AppleTV, etc. etc.
    I have high hopes specially since I care less and actually do not want to utilize Time Machine feature at all! I'm sure you geniuses have already figured this out. Please HELP!!!
    Any feedback would be greatly appreciated-
    Cheers!

    Tapori wrote:
    I've been trying the IP address which shows up on the welcome screen of AirPort Utility but that could be very much TC's Router Address cause it's showing up in AirPort Utility?
    How can I acquire IP address for TC's language 1TB Hard Drive? It can't be this difficult!
    well, as i'm digging deeper, finding the ip address isn't the issue, it's getting your software to record to it, maybe a permissions issue?
    is this open source? can i check it out and see if i can help you this way? if i can get my hands on it i'm pretty sure i'd be more help. if the software just needs an ip address, you got it... so there's another issue. it's in your internal network right? so internal ip's should be fine, no need to port forward...
    just brainstorming out loud.
    Good suggestion but how do you assign a static IP to a Mac Mini which is on the same network (both wiredly and wirelessly connected to TC)?
    open network prefs, select your ethernet connection, configure: using dhcp with manual address, enter ip address (even if it's the same as your DHCP address, this simply assigns it permantly), click apply.
    if you wanted to do this over the wireless network you'd choose the airport from the left, advanced, tcp/ip tab, configure IPv4: using dhcp with manual address, enter ip address (even if it's the same as your DHCP address, this simply assigns it permantly), configure IPv6: automatically, click apply.
    the ethernet connection would have a different IP than your wireless connection to give you the option to switch back and forth while maintaining assigned connectivity elsewhere in your network (ie. pvr ip recording).
    i'm just curious what permissions the pvr ip recorder would have, and where exactly it would record to... (as in which folder... as what user?)
    Message was edited by: BKRonline

  • Datagram Sockets possible without locally available IP addresses?

    Hi everybody,
    before starting to dig into socket programming for the next few months, I'd like to get some facts clear that don't clarify to me by consuming the developer handbooks.
    I would like to send datagram packets out on all interfaces without bound sockets, i.e. I want to start something similar to a DHCP broadcast. Is this possible with Java? AFAIK always sockets are required , even for datagram communication.
    Thank you

    Hi! Thanks for you replies.
    I'm trying to create some kind of alternative host configuration protocol with a reference implementation. Since the server software will run on Java for various purposes, it would be fine if also the client software could be implemented in Java. Therefore, I'd need the possibility to send out datagrams on unconfigured network interfaces.
    As far as I have understood the DatagramSocketAPI, there's always the need to have a local socket available (IP address + port number) to actually send data - is that true?
    Thank you!

  • How to create groups with non-local addresses

    I want to create a mailing group that consists of non-local addresses like [email protected], [email protected]
    How to do this ? I know that editing /etc/aliases redirects to local accounts only. The above is possible by editing /etc/postfix/virtual and do a postmap on this file. Is there any alternate way ?

    I use an include file for my groups - easier to modify...
    In /etc/postfix/aliases...
    some_groupname: :include:/path_to/groupname.txt
    In the 'groupname.txt' file (textedit, plaintext file), a list of the members...
    localemailuser
    [email protected]
    After any edit of the group file... sudo newaliases
    -david

  • Bypass Proxy for Local Addresses

    All-
    With the new 2.0 software, I am now able to connect my 3G iPhone to the WiFi network at work. The network uses an authenticated proxy to get external access. I can access external sites just fine now, but I can't see internal sites. The proxy settings on my work desktop give me the option to "bypass proxy server for local addresses".
    Is there any way to do this on an iPhone?
    Right now I need to make a choice between access only internal sites or only external sites.
    Thanks!
    MF

    While not wanting to be a total weenie, ME TOO
    After a bit of searching, the best we're going to be able to do right now is use a Proxy Auto-Config (.pac) file. I'm drawn to this conclusion from combining a lot of web searches with a peek at the "iPhone and iPod touch Enterprise Deployment Guide, Second Edition" (available at http://manuals.info.apple.com/enUS/Enterprise_DeploymentGuide.pdf, or via the Apple iPhone Enterprise support page at http://www.apple.com/support/iphone/enterprise/.
    Setting the PAC file using the iPhone v2.x software is pretty direct - click the little arrow next to the network you want to configure, scroll down to the bottom where the proxy settings live. Choose "Auto" and enter the Auto-config URL.
    That's the good news. The bad news is that I'm not entirely sure what that entails w.r.t. using one with the iPhone software. I'm not entirely clever enough to create such a file nor am I clever enough to know how to stick such a file onto my iPhone. I'm going to run this around my local team to see what they can come up with. If they come up with a solution (and it's simple enough for me to do AND explain), then I'll post a follow-up. Until then, good luck to you AND if you figure something out feel free to share with everyone else.
    Ron

  • Unable to set the ip address for hosted network client after creating WIFI hotspot

    Original Title: INTERNET CONNECTIVITY PROBLEM WITH MY LAPTOP WIFI HOTSPOT
    HI all
    I am able to use internet connection from my lap hotspot, when the internet source is Public or private wifi.
    so I know the cmd window commands for hotspot and settings of client(sharing to hosted network client, assigning IP address etc.,)
    but the problem I am facing is slight different
    I am using my cdma wireless broadband datacard as my source internet connection(Reliance netconnect +)
    when I try to create hotspot for this, as usual I am able to create the hotspot and able to share the internet to hostednework client.
    but I am unable to set the ip address for hosted network client, if I try to set ip 192.169.137.1 and 255.255.255.0
    as soon as I close the window, the ip address also disappears
    when connect my android phone to that hotspot, it is able to connect but there is no internet connectivity.
    when I check the hostednetwork client for packet transmission, both sent and received packet is happening., I mean transmitting
    so what cause the failure in internet connectivity but success in hotspot connectivity?
    check the screen shots...
    can u help me..
    its little complicated

    Hi,
    Please make sure the Ad hoc connection IP adress is at the same range with your local connection. In addition, how about recreate the ad hoc connection for test, please have a try.
    If problem persists, please use Network troubleshooter in Action Center to fix this problem for test.
    Roger Lu
    TechNet Community Support

  • Which IP address should I be using for a socket?

    I'm trying to create a socket to connect to my IP address. The problem is that I have an "outside" IP address and an "inside" IP address.
    According to http://whatismyipaddress.com/, my IP address is 97.100.76.196. But aside from that, my wireless internet router assigns different devices in my home different IP addresses. For example, on my computer, it is 10.0.0.9. So when I create a Socket, what would my parameters be since I essentially have 2 different IP addresses?
    new Socket("which IP address???", int port);Thanks so much!

    REisinger1 wrote:
    But if someone connects externally to THIS computer, how will only one IP address get them here?If someone outside your network (aka on the internet) is going to connect to your computer here is what will happen.
    1) They will connect to your routers public IP address. (the 97.x.x.x one you shouldn't have posted).
    2) You will set up the router to forward requests on port Y to port Y on your computer using it's internal addess (the 10.x.x.x one).
    Everything works.
    To do (2) is not a Java question but a question related to your router. So you'll have to read the documentation and if you have follow up questions ask them on an appropriate forum (not this one).
    There is another option as well but that requires you to have a second public IP address for your computer (which would make your computer on the Internet directly). I don't recommend this approach for you because you'd need a second IP from your ISP and there are a certain number of security considerations involved as well.

  • How to use a ip address for pop & smtp server names when creating a new account

    My xp PC is on a lan behind a Freebsd os [IE. flavor of unix] which is not running a dns server. The only way to reach it is by ip address. I have configured the account with a ip address for pop & smtp. When I create and sent a email, Thunderbird shows a window saying it trying to connect and after 10 seconds it goes away with out showing the status window. There is no email in the sent folder. Is it possible to do this ???? I can accomplish this using ms/outlook so I know it is possible.

    I haven't tried this in years, but could you give this server a name and enter that into TB
    Then in C:\Windows\System32\drivers\etc\hosts you add that name and ip

  • How do I create a new icloud email address for my apple id?

    Hi there
    How do I create a new icloud email address for my apple id? My original email address is associated with my previous employers.
    When I send email from my Macbook, it seems as if I still work there, which is a problem.
    I would like to use the email address that I created for my iPad.
    When I login with my appleid (for my macbook) I keep getting the old company one, not the new one.
    Is there any way of resolving this? I
    Thanks
    Kelvin

    Welcome to the Apple Community.
    Providing you aren't trying to change you Apple iCloud email address you can make changes at My Apple ID

  • Can I create an email address for a family member using my apple ID?

    I converted to iCloud from Mobile Me in October before I created email addresses for my kids.  Can I create accounts for them in iCloud?

    Just go to http://appleid.apple.com and create a new Apple ID for each kid - note that you will need a different associated email address for each ID, and different from your own, but you can use free addresses such as Yahoo.
    Then start a new iCloud account for each using the IDs. You will need to have a separate user account on your Mac for each kid (you should be doing this anyway, and they should be non-admin accounts) and then you can enter the ID in System Preferences>iCloud and create a new @me.com address in each case.
    Alternatively you could create up to three email aliases on your own account - these are addresses, not accounts, and deliver into your main inbox alonside your mail, so everyone will be able to see everyone else's mail, which may well not be what you want.

  • I created an Apple ID for my daughter with her own gmail address, but I want her Apple ID and primary email address to be an iCloud email address. How can I do this? I can't set up an icould email address for her without first creating an Apple ID?

    I have created an Apple ID for my daughter with her own gmail address as the primary email address, but I want her Apple ID and primary email address to be an iCloud email address. How can I do this? I can't set up an icould email address for her without first creating an Apple ID right?
    I'm not good with computers so please explain in simple way...:)
    I also wonder what the best way is to set up accounts for children in a family. I dont want them to be able to purchase apps etc through the parents accounts, also some things we like to share as a family and others we don't want to share. Is there any good. clear, simple explanation from Apple Support about these issues? Or best to go to Apple store and go to genius bar or one to one advise?
    thanks

    You can set up an iCloud account which makes the iCloud email address you choose the Apple ID and thus the login for it:
    https://discussions.apple.com/message/22283348#22283348
    though I have to say I think it's more sensible if the ID is another address, both for security reasons (so people don't know what the login is) and as a contact address from Apple if the account were to stop working and they needed to contact you. So personally I would to to System Preferences, enter the GMail address which is an ID, and then choose a nerw @icloud.com address.
    If she has her own iCloud account she will need either her own computer or her own user account on your Mac to be able to make use of it. You should note that under Apple's terms of use Apple IDs are only available to children of 13 and over.
    As to purchasing apps, this is nothing to do with iCloud: it's iTunes, and the login can be different. So you can all sign into the same iTunes account but have different iCloud accounts. Or she can have her own iTunes account if she is of suitable age (credit card needed for purchasing apps).
    If you have other children you should be aware that any one Mac or device can create only three iCloud accounts - this is tied to the serial number, not the user account, and once reached cannot be bypassed. You can of course sign into an iCloud account created on another device.

Maybe you are looking for

  • How do I connect my apple id with my icloud?

    I have a valid Apple Id but I cannot get into icloud because it is not a icloud account.

  • Pop up text boxes on mouseovers

    I'm looking for an easy way (and the easiest tool to use between Dreamweaver, Fireworks, and Flash [and I'm guessing 'Fireworks']...or maybe Flash---I have Studio MX2004) to create not a 'pop-menu', but 'a Pop-Up TEXT box' on a mouseover event. For e

  • New name for the product?

    The name Oracle Express Edition seems to be causing a bit of confusion as there is already an Oracle Express in the stable, some kind of OLAP tool. So I was just wondering why Oracle went for a name so close to an existing product. I have a couple of

  • Remove unnecessary transport requests which are 7 days old

    Hi All, I would like to delete all the un-necessary transport requests which are displayed in STMS which are more than 7 days old. But, the import log should be available whenever i need to verify. Is there any script which can do this? Thanks Vijay

  • New Email counter missing in Safari tab?

    Hi folks. My ATT Yahoo mail page used to indicate on my Safari tab if new unread mail had appeared.  Since going to ML and Safari 6, that has stopped and I dont know how to restore it.  I found that there are widgets for gmail to do that, but I cant