Reading the same port on the same machine

Hello,
i'm working on DatagramSocket to broadcast DatagramPacket (IP 192.168.xxx.255) and a fixed num port. The problem is that I can't have 2 threads that read (datagramSocket.read) on the same port, on the same machine.
How can I perform my tests ?
java.net.BindException: Address already in use
at java.net.PlainDatagramSocketImpl.bind(Native Method)
at java.net.DatagramSocket.bind(DatagramSocket.java:368)
at java.net.DatagramSocket.<init>(DatagramSocket.java:210)
at java.net.DatagramSocket.<init>(DatagramSocket.java:261)
at java.net.DatagramSocket.<init>(DatagramSocket.java:234)

Well, the short answer is that you can't.... at least I've never heard of a way how. Basically, when an application requests a port number, it basically owns that port number until it gives it up. You do this when you create the DatagramSocket. Each DatagramSocket is its own request, and therefore must have an unique identifying port. Otherwise, how would your operating system know who to give the data to when it receives a packet on your machine for port XXXX? Also, it would be a secuirity problem if other applications could listen on the same port as you use for other things like surfing the web, making online purchases, email.
However, what you could do is have one owner of the DatagramSocket... and share it among the other threads. When that owner receives a packet, it can notify the other threads it received a packet and pass the data to each one. Set it up something like how listeners work. Also, if you want it to span processes, you could use RMI or pass the data through other deined network connections between the processes.
Does that make sense? :)

Similar Messages

  • HT3924 Why TDM exclusive to the iMac? Shouldn't any Mac from 2009 with the correct port have the same option?

    Why Target Display Mode exclusive to the iMac? Shouldn't any Mac from 2009 with the correct ports have the same option? Is there a physical limitation that prevents MacBook Pro/Air notebooks with thunderbolt ports from entering Target Display Mode? Or does someone just need to poke the OSX development team with a stick?

    that was the route I took this time when I updated to 10.5.6 - the downloaded combo updater rather than the smaller (half the size) Mac updater...
    Pretty sure this is a combination of MTU, 2Wire 2701 oddities and me not knowing how to solve them directly (as well as the ipv6 stuff that's still showing in the logs despite IPv6 being turned off).
    Anyhow, I did get it connected under the Ambit finally (took restarting the mac, not expecting that in the "switch" from windows xp)- and that really rocked. Now I'm working on teaching my 2Wire to be a dumb modem, to go with the operator
    Actually, I think I'll just cut my losses for the moment and go with cable, once I find a good wireless router to connect the media center and xp box up front.

  • I buy new iPhone5s befor 11day but. Now don't work    I tried restore but same result I went to the nearest repairer and replace the battery and the charging port and the monitor but same result, I failed, said mother Bord (Raja solution)

    I buy new iPhone5s befor 11day but. Now don't work    I tried restore but same result I went to the nearest repairer and replace the battery and the charging port and the monitor but same result, I failed, said mother Bord (Raja solution)

    If you bought the iPhone from an authorized store/vendor, you should have taken the iPhone to them or any other Apple Store for evaluation under warranty.
    Once it has been opened by non-Apple entity, Apple will not do anything for this.

  • Is the thunderbolt port on the new MBP 13' the same as a mini displayport?

    sorry if this is a silly question..

    I think that the Thunderbolt port offers the same function as the Display port.
    This a working solution that I have, which uses the Thunderbolt port for both Thunderbolt and Display port use:
    Macbook Air (mid 2011) - connect to Seagate GoFlex Desk Thunderbolt Hard Drive (Using Thunderbolt cable)
    Seagate Goflex Thunderbolt passthrough (it has 2 thunderbolt ports) to a Dell 24 Inch monitor (using Apple Mini DisplayPort to Dual-Link DVI Adapter cable).
    Both the Seagate GoFlex and the Dell 24 inch monitor work :-)

  • Can two different local ips use the same port at the same time?

    Can two PS3s use the same ports at the same time. So let's say you have two PS3s and they need to open the exact same set of ports at the same time to be able to play the same game online. Is that possible on a regular consumer router such as the wrt310n? If so, then how would someone go about that. I am just asking out of curiosity.
    I don't work for Cisco. I'm just here to help.

    Use port range Triggering instead of Port forwarding. When you use port triggering then those ports will be opened for the entire local network.

  • Is it possible to use both an ILB and an ELB (listening on the same port) in the same Azure cloud service?

    I'm building a test Lync deployment on Azure; yes, I know this is not supported, hence "test".
    Lync Front-End servers expose two set of web services, one for internal users and one for external ones; they listen on different ports (443 and 4443) on the same servers; when external services are published, you need a reverse proxy or a port forwarding
    in order to map port 443 of a public IP address to port 4443 of the Front-End server(s). When you have multiple Front-End servers in a pool, you also need to load-balance them.
    So, a typical Lync deployment looks like this:
           Internal users
                     |
                   443
                      |
              Internal LB
            192.168.0.20
            443         443
              |               |
       Lync FE 1     Lync FE 2
    192.168.0.21 192.168.0.22
              |               |
          4443        4443
              External LB
           Public IP Address
                     |
                  443
                     |
           External Users
    This should be easily replicated in Azure, as it supports both external load balancing and internal load balancing. They are even supported together in the same cloud service, so this configuration should be easy. However, it looks like "should"
    is the keyword here.
    After creating the external load balanced endpoint (which listens on external port 443 and forwards to port 4443 on the servers), I'm trying to create an internal load balancer and add internal endpoints to is; however, while the ILB can be created successfully,
    adding an internal endpoint listening on port 443 and forwarding to port 443 on the servers fails miserably, with an error stating that port 443 is already in use by another endpoint:
    Update-AzureVM : BadRequest : Port 443 is already in use by one of the endpoints in this deployment. Ensure that the port numbers are unique across endpoints within a deployment.
    For reference, my commands are:
    Add-AzureInternalLoadBalancer -InternalLoadBalancerName "LyncILB" -ServiceName "LyncFrontEnd" -SubnetName "LabSubnet" -StaticVNetIPAddress 192.168.0.20
    (This completes successfully)
    Get-AzureVM LYNCFE1 | Add-AzureEndpoint -Name "Https-Int" -Protocol "tcp" -LocalPort 443 -PublicPort 443 -LBSetName "HttpsIntLB" -DefaultProbe -InternalLoadBalancerName "LyncILB"
    (This fails)
    The existing external endpoint is configured as such:
    Get-AzureVM LYNCFE1 | get-azureendpoint
    LBSetName : HttpsExtLB
    LocalPort : 4443
    Name : HTTPS-Ext
    Port : 443
    Protocol : tcp
    Vip :
    ProbePath :
    ProbePort : 4443
    ProbeProtocol : tcp
    ProbeIntervalInSeconds : 15
    ProbeTimeoutInSeconds : 31
    EnableDirectServerReturn : False
    Acl : {}
    InternalLoadBalancerName :
    IdleTimeoutInMinutes :
    LoadBalancerDistribution :
    The error doesn't even make a lot of sense; the external load balancer listens on a public IP address, while the internal load balancer listens on a private IP address in the internal network; there
    shouldn't be any conflict here... however it looks like there is one instead.
    Why doesn't this work? Am I doing something wrong, or is Azure networking just being silly as usual again?

    Hello Massimo Pascucci,
    The issue that you are facing when creating an endpoint with internal loadbalancer is the limitation of not allowing same ports to be listening under a single cloud service. This reason for this is that there is a limitation of only one private IP (Also
    known as the Internal load balanced IP) per cloud service.
    There is also a limitation on the Internal load balancer more than one port to be published per load balancer:
    You can leave your feedback by following the link below:
    https://social.msdn.microsoft.com/Forums/en-US/1805c5a0-3906-4cd6-8561-9802d77e0ae5/is-it-possible-to-use-both-an-ilb-and-an-elb-listening-on-the-same-port-in-the-same-azure-cloud?forum=WAVirtualMachinesVirtualNetwork
    Refer to this article for more information on Internal load balancer:
    http://azure.microsoft.com/blog/2014/05/20/internal-load-balancing/
    Thanks,
    Syed Irfan Hussain

  • I want to transfer data through the serial port in the same coding that hyperterminal uses. How can i do it?

    The serial port seems to be working, and labview seems to be sending the data, but the problem is in which format does it send the data, because in hyperterminal i just input the string "JDX" and it sends it to my device, with labview it sends something but my device does not recognize it.

    nobuto wrote:
    > I want to transfer data through the serial port in the same coding
    > that hyperterminal uses. How can i do it?
    >
    > The serial port seems to be working, and labview seems to be sending
    > the data, but the problem is in which format does it send the data,
    > because in hyperterminal i just input the string "JDX" and it sends it
    > to my device, with labview it sends something but my device does not
    > recognize it.
    Hyperterminal adds the carriage return/line feed to the string which is
    generated by the return key to send out the current line. LabVIEW simply
    sends out what you tell it, so try to set the string to "Show \ Display"
    format and add a \r or \n or \r\n to the command you want to send out.
    Assumes of course that you set the right baudr
    ate/bits/parity etc in
    LabVIEW with the VISA property node, when opening the serial port.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • HT4356 I have an older HP connected to the usb port of my Time Machine, and have it shared.  I want to print from my iPhone on the network, but it can not be found in airport?  How do I make this work?

    I have an older HP connected to the usb port of my Time Machine, and have it shared.  I want to print from my iPhone on the network, but it can not be found in airport?  How do I make this work?

    AirPrint printers connected to the USB port of the Apple AirPort Base Station or Time Capsules are not supported with AirPrint.
    Read through this for information about Airprint printers and how to use them:
    http://support.apple.com/kb/ht4356

  • Can a USB Keyboard/Barcode reader be used with the USB port on the CRio

    Is it possible to use a USB Keyboard or Barcode reader with the USB port on the CRio, I know you can use this port with a USB memory device, but what about other devices?
    I have a project that requires that all hardware elements be connected to the controller and use the HMI purely for display,
    anybody any ideas?? 

    Hi kmoyna,
    The standard CompactRIO range's USB host ports are not suitable for standard USB devices like keyboards or barcode readers - they are intended only for use of mass storage devices. From your description, it seems your project's requirements would be best met by the newer models, cRIO-9081 or cRIO-9082. These two units have Windows Embedded Standard 7 (WES7) and allow the direct connection of a monitor and standard USB devices. We now also have similar stand-alone CompactDAQ models running WES7 - cDAQ 9139.
    I would recommend calling into your local branch to discuss your project further with one of our engineers. If you're in the UK, it's 01635 523 545 - or view contact details for other branches.
    Regards,
    Imtiaz Chowdhury
    Head of Digital Technologies
    Brand786

  • How to view the open ports of a remote machine?

    is ther anyway for java to view the open ports of a remote machine.
    i am developing a remote desktop sharing program...i remotely control a user's machine on LAN. so i sometimes need to launch a website,launch an application, or give a message to the user on the remote machine from
    my console.
    so please help me in providing the java code to implement the above features.

    What you are asking, it the first step towards the dark art. But then, why make a tool for yourself, I am sure there would be plenty available.
    Ironluca

  • Can anyone explain when the USB port on the Express is really needed?

    Back with another question!
    My Airport Express is used only for my Canon printer (MP980), nothing else. I know, with hooking up my new Mac Mini, I'll get new drivers from Apple and will need to install some of the updated software from Canon... from what I've read, I won't try to use the disc that originally came with the printer.
    Since I'll join my Airport network for printing after my older Mini is disconnected, when is there a need to use the USB port on the Express? I've read that it's used for connecting multiple computers to the network. But, I'm having some confusion with this. With my network up and running, I assume I would be able to use my old Mini and the new Mini on the same network, if I decided to unplug one and use the other one for a short time, since my network settings won't change. (I have but one monitor!). Is a USB connection to the printer only required if multiple computers are shared simultaneously with the printer via Airport Express?? I never really understood this completely. All I expect to do for a few months is occasionally unplug one Mini for the other as I save some files onto disc, etc.
    Did I make sense?

    JiminReno wrote:
    Back with another question!
    hello again, jim !
    Since I'll join my Airport network for printing after my older Mini is disconnected, when is there a need to use the USB port on the Express?
    you can hook up a printer (or a Keyspan remote to control iTunes). one aspect may be location. what if you want the printer in a different room or on a different floor in the house ?
    I've read that it's used for connecting multiple computers to the network. But, I'm having some confusion with this. With my network up and running, I assume I would be able to use my old Mini and the new Mini on the same network, if I decided to unplug one and use the other one for a short time, since my network settings won't change. (I have but one monitor!).
    yes, you can also share a printer connected to your mini with other client machines.
    btw, you could use the +screen sharing+ feature to access and manage the screenless mini.
    Is a USB connection to the printer only required if multiple computers are shared simultaneously with the printer via Airport Express??
    no, all machines on your network could use a printer connected to either of your mini's or connected to the AX.

  • 6500 with 2 SUP's/do the GIG ports on the backup SUP work, when in backup?

    Hey I'm bout to install a 6500 series with 2 SUP engines, one for primary and one for backup in the same chassis.
    My question is: Do the fiber/GIG ports on the backup SUP engine work, when it is in backup mode, or ONLY when the SUP engine is in primary mode???
    thanks,
    cisco80211
    Chris Serafin
    IT Security / Cisco VoIP Engineer
    [email protected]

    Hi Chris,
    The gig ports on the standby supervisor are absolutely functional, and the converse is true in the event of a switchover.
    Documented here:
    http://www.cisco.com/en/US/products/hw/switches/ps700/products_installation_guide_chapter09186a0080123ecd.html
    "The uplink ports are fully functional on the redundant supervisor engine in standby mode"
    HTH,
    Bobby
    *Please rate helpful posts.

  • Is the USB Port in the front of G5, USB 1.1

    Hi All,
    Can anyone confirm this? Is the USB port in the front of the G5 only USB 1.1? I hooked up a USB hard drive to the front port and the transfer speeds were super slow. I checked the system profiler and it said the max speed was 12Mbs. Then I hooked that same USB hard drive to the back USB port and the speeds increased significantly. I checked the system profiler and it said the max speed was 480Mbs. I thought all the USB ports on the G5 were USB 2.0, or is my front USB port dying ? Please confirm. Thanks.

    The USB ports on the G5 itself are USB 2.0. Those on the keyboard which came with it are USB 1.1.
    (44423)

  • I have an iMac and also a MacBook. All of a sudden my iMac does not recognise my Canon 500D camera even though I have downloaded 1000s of photographs from it via the USB port.  The MacBook recognises the camera immediately. Can anyone help?

    I have an iMac and also a MacBook. All of a sudden my iMac does not recognise my Canon 500D camera even though I have downloaded 1000s of photographs from it via the USB port.  The MacBook recognises the camera immediately. Can anyone help?

    Thank you for your reply.  I know I can use a card reader however I don't see why I should when importing directly from my camera has worked reliably for years.  The process I use is simply connecting the digital output from my camera to the USB port on the iMac, which has previously automatically opened iPhoto ready for the import.  Now all of a sudden my iMac does not recognise the camera.  However if I connect in the same way to my MacBook then iPhoto opens automatically on the MacBook, recognises the camera and is ready for importing.  So whilst I know I can use a reader, or my MacBook I want to use my iMac in the same way that I have for years.  I can only assume that the settings on the iMac may have changed, but I cannot verify this.

  • Generated Pulse waveform is distorted when I deliver the signal to the output port in the DAQmx

    Problem: Generated Pulse waveform is distorted when I deliver the signal to the output port in the DAQmx.
    Environment: Windows XP sp3 (32bit), Visual Studio 2010 sp1, NI-Measurement Studio 2010
    Device: NI - DAQmx PCI 6251
     Analog Input: 1.00MS/s multi-channel (aggregate)
     Analog Output: 2 Channel 2.00MS/s
    Reference Example: AO_ContGenVoltageWfm_IntClk / AI_ContAcqVoltageSamples_IntClk
    Generated Pulse:
    1) AO0 = Square Waveform /0-5V / 8KHz / 0.5㎲/sample / sample 50% Duty
    2) AO1 = Square Waveform /0-5V / 8KHz / 0.5㎲/sample / (Reverse Image)
    Description: I’d like to deliver the waveform stream satisfied with specified constraints to the 2 channel output port in the DAQmx. To verify accuracy of the generated waveform, I did an electrical wiring from the Analog output channel (2 channels) to the Analog Input channel (2 channels) in DAQmx. As a result of this experiment, I could get a result which has signal distortion. Since the waveform has to satisfy with both high frequency (8KHz) and very short moment interval time (△t = 0.5㎲/sample) between samples, I cannot handle some parameters of the function in the referenced VC++ example. Following formulas shows an approach to deliver the generate pulse waveform to output port satisfied with constraints.
    Analog Output Channel
     Frequency = 8,000 cycles/sec (constraint)
     Sample per Buffer = 2,000,000 = 2*106 samples/buffer
     Cycles per Buffer = 80,000 cycles/buffer
     Sample per Channel = 1,000,000 = 1*106 samples/channel
     Sample Rate  = Frequency * (Sample per Buffer / Cycle per Buffer)
                              = 8,000 * (2*106 / 80,000) = 2*106 samples / sec
     △t  = 1 sec / 2*106 samples / sec
               = 0.5 * 10-6 sec/sample (constraint)
     Buffer Cycle  = Sample Rate / Sample per Channel
                              = (2*106 samples / sec) / (1*106 samples/channel)
                              = 2 channel / sec
    Analog Input Channel
    Sample per Channel = 1,000,000 = 1*106 samples/channel
     Sample Rate  = 1 MS/s * (2 Channel) = 5 * 105 Samples / Sec
    Program Code
    AO_ContGenVoltageWfm_IntClk / AI_ContAcqVoltageSamples_IntClk (VC++ Example)
    Result: The proposed approach was implemented in the experiment environment (VS2010, MStudio2010). As shown in Figure 1, we could get the unsatisfied result. Although I intended to make a ‘square’ pulse wave, the result looks like ‘trapezoid’ pulse wave (Figure.1). However, there is other result which was undertaken with different parameter condition. It looks like the square shape not the trapezoid shape.
    Please let me know what the conditions make the problem of signal distortion. (AO0 = Green line / AO1 = Red line)
    [Figure. 1] Frequency 8000 Hz / Cycle per Buffer = 8000 Result
    [Figure. 2] Frequency 1000 Hz / Cycle per Buffer = 1000 Result
    Questions: Please let me know following questions.
    1) Is it possible to deliver the generated pulse wave satisfied with constraints (f= 8KHz), △t = 0.5㎲/sample) to the output port without distortion using PXI 6251?
    (Is it possible to solve the problem, if I use the LabView or MAX?)
    2) Are there some mistakes in the proposed approach? (H/W or S/W program)
    3) What is the meaning of the Cycle per Buffer?, It could effect to the result?

    Hi Brett Burger,
    Thanks for your reply. For your information, I have set the sampling rate as 10000 as for the sound format, I have set the bits per sample as 16 bit, the rate as 11025 and the sound quality as mono. I tried using your method by changing the sampling rate as 8K but still my program encounter the same problem.
    I wish to also create a button that is able to generate a preformatted report that contains VI documentation, data the VI returns, and report properties, such as the author, company, and number of pages only when I click on the button.  I have created this in my program, but I am not sure why is it not working. Can you help troubleshoot my program. Or do you have any samples to provide me. Hope to hear from you soon.
    Many thanks.
    Regards,
    min
    Attachments:
    Heart Sounds1.vi ‏971 KB

Maybe you are looking for

  • Is there a way to create a text field that shows on all slides?

    I'm trying to create a "Revised On" date field that can be shown on every slide. Or, do I just have to copy and paste on all slides? Thanks in advance. - Michael

  • Authorization check for Easy Document Management

    Hello, I'm using ECC6 without cProjects or any other implementations regarding the authorization concept in Easy DMS. I'm trying to use authorization control inside the Easy DMS GUI but these settings won't work. I need document based authorization a

  • Excel import on Oracle Linux - How to create an ODBC Connection

    Hi, We have Oracle BI EE on Oracle Linux. We need to create an ODBC DNS and import tables to Admin tool. How would you create a ODBC connection inside Linux to Microsoft excel file using unixodbc. What drivers we need. Please let us know. Thanks! Nil

  • Photo Albums in Random Order

    I have recently moved from Aperture to Lightroom because Apple are no longer going to develop Aperture. Needless to say I have to create new photo albums to be able to view on ATV, which I've done. Now when I point iTunes to the folders of albums the

  • Connect Oracle 9 client from windows 2012 server to 9.0 oracle database

    I have windows 2012 64 bit with installed oracle 9.0 32 bit client and i want to connect to oracle 9.0 64 bit server installed on windows 2003 R2 64 bit Is it possible to make this connection because when i have tried to connect received this error O