How to specify a local port but it should not be bound

Hi all,
i am developing a client app that connects to a server...
for example i have the constuctor of a socket that connects to a server..the server requires the ipaddress and local port of the client for security reasons...so my socket constructor looks like this client = new Socket (remote ipaddress, remote port, local ipaddress, local port) ..this works fine...but the problem is that the server sends messages to the local port.....how do i make sure that java does not bind..the local port..i mean for it to be freed..cos it seems java is binding it.
Thanks.

there is a Server (Not a java program) that requires
clients to connect to it using the following kind of
connection below:
a java client connects to the server with this socket
constructor
Socket ss = new Socket (remote ip, remote port, local ip, local port);This is your first problem. There is no such kind of server. The server will know the client's local port regardless of which Socket constructor the client uses, as someone else pointed out. Leave out the last two parameters.
now the
server sends responses to the local port specified in
the constructor of the socket.or the local port assigned by the system if it wasn't specified, as it almost always shouldn't be.
I need to create a listener on the localport
so i can read the information sent in from the serverAHA!!!!!!! NO YOU DO NOT. You need to execute a read on the client socket. That's what it's for. It already represents an established connection between a client local port and the server.
..creating
this ServerSocket ss = new ServerSocket
(localport); in jave generates an "Address
Already in Use Exception".As expected. It is.
now what i asked was "how
can i unbind the local port form the socket so java
will not tell me it is already in use when creating a
listener on it in ServerSocket".You don't want to do this as explained before. FYI you could close the Socket to release the port, but you will then discover that the server sends fail because it tries to send to the established connection.
I hope this is clear now.Clear as mud. What is clear is that you do indeed need to read up on TCP/IP as recommended by several other posters. Your grasp is very slender.

Similar Messages

  • HyperTerminal sees a COM port but VISA does not

    It should not be possible that HyperTerminal sees a COM port but VISA does not. Does anyone know why or have any ideas?
    Here's some more info: I wrote a LabView (LV) program and deployed it (via the Application Builder) to some of our production department's PCs (some Windows XP and some Windows 7). We use it to set up products we design and manufacture through our device's USB serial port. The USB port is actually a virtual COM port (VCP) - a USB to Serial converter or "bridge". We have a custom driver for our device and since each device's USB bridge chip is programmed with a different serial number, every time we connect a new device to the PC the installer runs and assigns a new COM port number. This is so our customers can use multiple devices on a PC. Fine. On one of our production PC's we were close to  COM900 ports (HyperTerminal sees only up to COM256) when suddenly Win7 would not allow any more. We were able to uninstall orphaned (non-present) COM ports from DeviceManager ("DM") by starting it from a command console (DOS window) with a special command-line switch, "set devmgr_show_nonpresent_devices=1" then "start devmgmt.msc" (I have this in a batch file). In DM View menu you can "Show hidden devices" and uninstall them as if they were connected. I've also tried uninstalling them the normal way when the device was actually connected. Either way, sometimes, not always, depending on the COM port number, after reusing that port number by installing a new device which picks up that old, freed-up number, LV VISA doesn't see it. In other words, when "Refresh" is clicked in the COM port VISA list box, any new devices installed should be and normally are seen. (Refresh is not needed if the application is started after the device's driver is installed. It is only need if the LV application is open with the new device is added.) However, HyperTerminal does see it and lists it in the Properties screen, the "Connect using..." list box. And the port works with HyperTerminal. (Of course we've tried rebooting after uninstalling and/or reinstalling the device, with the same results.)
    When I've spoken to the NI Applications Engineers in the past about serial port issues (not about this problem) they have confirmed that if HyperTerminal can see the port then NI VISA should also see it. This is crazy. I am posting this in hope that someone can shed some light on this problem.
    Thank you. -Ed

    Good catch. Yes, we're using the Silicon Labs CP2102 and have created a "custom driver" installation package. Our new PCBs have a factory-programmed chip, so the PC reuses that COM port (COM3 on that PC). The problem is when we we re-program the CP2102 (setIDs exe) with our PID, and device strings (including the S/N), the PC runs our installer and assigns the next COM port number. I was hoping that maybe it would go up to 64K or something! Anyway, it surpassed COM256 but we ran into this problem when almost up to COM900.)
    There is a registry entry for each SN device, which shows the assigned port. If we delete the key with regedit, the COM port database (don't know the file name) still has the port number. That's where Device Manager comes in. It seems to allow us to manually delete the ports, but it would take quite a while to delete 900. (I was trying to make a batch file for DevCon, but couldn't get it to see the HW ID of the devices in need of deletion.) So we tried manually deleting a few. After doing that Device Manager shows that Windows (and HyperTerminal) can reuse the port number when a new device (new SN) is installed, but, as you know from this post, VISA cannot see unless I manually add it in MAX.
    I can't see how it has anything to do with the Silicon Labs driver. I might have to delete ALL of MY devices, then uninstall the driver files, reboot, then reinstall, as you suggested with the SiLabs driver. However, I don't see how VISA will now see these changes. VISA must have it's own database. That's what I thought deleting the ports in MAX would clear out, like a fresh install, but apparently not.
    I've been through Silicon Labs' tech support on other issues and they've been able to help on some. I could run this by them.
    BTW, have you noticed that Silicon Labs' chip and driver, while faster than NI's own "bridge" or serial-USB converter (I returned it because at $100 it's performance was worse than a $20 converter you can buy in Staples), is substantially slower than a real serial port? For example, our device can transmit 250 readings per second (a 12 byte string). A real serial port used with my LabView program can keep up, i.e.., graph & tabulate at that rate, but with a VCP we only get about 70 RPS. Same code. Can't figure this one out. They say the've tested the driver to 900 KB claimed. We're using 115KB here. Anyway, the VCP driver makes it look like a COM port which LV thinks it is. Why is it slower than a real port when the USB should be able to work almost 10 times faster than I'm using it (up to 1024 bytes per mSec per the full-speed USB spec, which SiLabs claims they verified)?
    Anyway, I appreciate your help. Thanks! -Ed

  • HT4623 how to update iphone 4 software but there's not a choice to update software in settings tab? Thoughts

    how to update iphone 4 software but there's not a choice to update software in settings tab? Thoughts

    Welcome to the Apple Support Communities
    Connect the phone to the Mac or PC and iTunes will ask you to update to the most recent version

  • When I updated the new version and used icloud, some of the apps are missing, how can I find those apps(but i was not using my account to download some apps before). Please advise.

    When I updated the new version IOS5 and used icloud, some of the apps are missing, how can i find those apps (but i was not using my account to download some apps before).  Please advise.

    They are free to iOS 7 users who have activated their NEW device on Sept 1 2013 or after. They are NOT automatically free with iOS 7.
    AirDrop is only compatible with iPad 4th gen and iPad mini. iPad 3rd gen and below do contain the necessary hardware for AirDrop. Also, AirDrop is only compatible between iOS devices. You cannot AirDrop between iOS device and Mac OS.

  • After installing IOS6: after erasing the history of Safari, the next time I fire up Safari, I see a split-second of the last displayed screen of Safari. Not a big issue but it should not be that way.

    After installing IOS6:
    After erasing the history of Safari, the next time I fire up Safari, I see a split-second of the last displayed screen of Safari.
    Not a big issue but it should not be that way.

    Download a new copy of the Firefox program: http://www.mozilla.com/firefox/all.html
    Trash the current Firefox application to do a clean reinstall.
    Install the new version that you have downloaded.
    Your profile data is stored elsewhere in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder], so you won't lose your bookmarks and other personal data.

  • How to put condition for one date range should not interfear with another ?

    hi friends,
    how to put condition for one date range should not interfear with another  date range.
    my data base table has two fields
    from date
    to date.
    when we enter the date range in the data base , new date range means from date and to date should not interfear.
    can  anybody help me.
    thanks &Regards,
    Revanth
    Edited by: rk.kolisetty on Jul 1, 2010 7:18 PM

    Do it the SAP way....
    First entry...from is today, to is 99991231.
    New dates entered, now we have two rows...:
        from is original date  to becomes yesterday.
        From is today          to is 99991231

  • How to specify one ethernet port for network home directories (other for normal filesharing)?

    So I'm trying to get Home Directories up and running on a 10.6.8 Xserve (waiting until I get my NFS sharepoints migrated to a Linux server [for other reasons] before moving up to 10.7 Server). But posting here since that will be happening in the next few weeks, and it might be applicable now (so I can at least get that resolved ahead of time).
    I have a different DNS entry for each ethernet port: server.office.domain.com at 192.168.0.11 for the first, and homes.services.internal at 192.168.0.10 for the second. DNS lookups for both resolve correctly (as does the reverse lookup).
    If I use the Server Admin to pick a sharepoint as an automount for Home Directories, everything is fine, but it picks the server.office.domain.com hostname. Picking that works just fine, but that is also the connection that feeds the filesharing. I'd prefer to split that home directory traffic out onto the second ethernet port. So I tried just duplicating the initial connection (since it can't be edited directly in Workgroup Manager) and changing the hostname to the internal one, but I get an error when attempting to log in (the client login screen gives a very helpful "Couldn't login because of an error" error message) and don't see anything in the server logs.
    The client machine shows the following line:
    Code:
    10/20/12 5:27:42.688 PM authorizationhost: ERROR | -[HomeDirMounter mountNetworkHomeWithURL:attributes:dirPath:username:] |
         PremountHomeDirectoryWithAuthentication( url=afp://homes.services.internal/Users,
         homedir=/Network/Servers/homes.services.internal/Volumes/HomeDirectories/Users/ user123, name=user123 ) returned 45
    (added line breaks so it didn't extend off the page)
    So it looks like this is failing because the automount isn't in place, but I'm not sure how to work that out either (i.e. how do I add that making sure it uses the internal hostname?).
    Any suggestions on getting this to work?
    I realize one solution is just to LACP the two ports, but that is a different ball of wax (I may do that later if I get a 4 port ethernet card and performance limitations demand it).

    A possible solution might be this.
    On ADSLBOX and CABLEBOX configure different subnets for the LAN, e.g.
    ADSLBOX:    192.168.1.0/24
    CABLEBOX: 192.168.2.0/24
    The MEDIABOX gets these static IPs:
    ADSL-LAN: 192.168.1.2
    CABLE-LAN: 192.168.2.2
    On the MEDIABOX, configure the two network interfaces using two routing tables.
    The ADSL-LAN routing table
    ip route add 192.168.1.0/24 dev eth0 src 192.168.1.2 table 1
    ip route add default via 192.168.1.1 table 1
    The CABLE-LAN routing table
    ip route add 192.168.2.0/24 dev eth1 src 192.168.2.2 table 2
    ip route add default via 192.168.2.1 table 2
    The main routing table
    ip route add 192.168.1.0/24 dev eth0 src 192.168.1.2
    ip route add 192.168.2.0/24 dev eth1 src 192.168.2.2
    # use the CABLE-LAN gateway as default, so general internet traffic from MEDIABOX runs over CABLEBOX
    ip route add default via 192.168.2.1
    define the lookup rules
    ip rule add from 192.168.1.2 table 1
    ip rule add from 192.168.2.2 table 2
    To test the setup:
    ip route show
    ip route show table 1
    ip route show table 2
    I don't know how to persist something like this in ArchLinux using netctl. Might require to write a special systemd unit for it. Above is a working example from a RedHat box at my company.
    Last edited by teekay (2013-12-04 07:42:22)

  • Group policy - restricted groups. How to specify a -local- user as member of the administrators group in group policy

    Hi
    With restricted groups I can specify the end user -domain- accounts that are members of the local administrators group on domain PCs. But - I need a particular LOCAL account on all the machines to keep its membership of the local administrators group for testing reasons. At the moment restricted groups is striping this local account of its admin access.
    Is it possible to specify a -local- computer account as admin on all the PCs via group policy or it can only be done with domain accounts?
    thanks

    You are asking for local accounts to be managed via "Restricted Groups".
    Yes, it is possible.
    Rajesh showed you one way with domain groups. In his version "Administrators" group will only contain those accounts
    that are specified in the GPO, no manually added accounts. This is not always desired.
    If you wish to have an account (group or user, local or domain) to be added to "Administrators" group while keeping all the other
    members, proceed like this:
    - create the local account on the client(s)
    - in the GPO select "Add Group" in "Restricted Groups".
    - type in the name of the local account, e.g. "TestID"
    - in the appearing dialogue choose "This group is a member of" => Add
    - type in "Administrators"
    Link the GPO and that's all.
    The original MS description for "Restricted Groups".is here:
    http://support.microsoft.com/kb/279301/en-us
    Another nice one here:
    http://www.frickelsoft.net/blog/?p=13
    Besides that, a great solution to manage local accouts is GP Preference Extension "Local Users and Groups".
    You can simply create a "Local Users and Groups" Item (computer or user based) and specify the needed options.
    http://technet.microsoft.com/en-us/library/cc731972.aspx
    Of course you need some prerequisites (at least one Vista or Winows 2008 for management and the GPP CSE on each target machine).
    If you are new to GPP, these links will help you to get into it:
    http://www.microsoft.com/DOWNLOADS/details.aspx?familyid=42E30E3F-6F01-4610-9D6E-F6E0FB7A0790&displaylang=en
    http://support.microsoft.com/kb/943729/en-us
    http://technet.microsoft.com/en-us/library/cc732027.aspx
    http://technet.microsoft.com/en-us/library/cc731892(WS.10).aspx
    Patrick

  • How to specify an SMTP port rather than 25 in JavaMail?

    This is my segment of code, but I don't know where I can specify the SMTP port. Please help me.
    Properties props = System.getProperties();
    props.put("mail.smtp.host", "smtp.mail.yahoo.com");
    Session session = Session.getDefaultInstance(props,
        new MyAuthenticator("dxxvi", "nopassword"));
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress("[email protected]",
                                        "Thai Dang Vu"));
    message.addRecipient(Message.RecipientType.TO,
        new InternetAddress("[email protected]"));
    message.setSubject("I test the Yahoo! Mail Plus service");
    message.setSentDate(new Date());
    Multipart multipart = new MimeMultipart();
    BodyPart bodyPart = new MimeBodyPart();
    bodyPart.setText("If you can read this, $19.99/year is worthy");
    multipart.addBodyPart(bodyPart);
    bodyPart = new MimeBodyPart();
    bodyPart.setDataHandler(
        new DataHandler(new FileDataSource("Resume.doc")));
    bodyPart.setFileName("Resume.doc");
    multipart.addBodyPart(bodyPart);
    message.setContent(multipart);
    Transport.send(message);

    props.put("mail.smtp.port", "42");

  • How can I know a port being used or not

    Hello, I have a trouble, I don't know how to realize whether a port has been used or not.
    For example, I have some command:
    ServerSocket server1 = new ServerSocket(2001);
    ServerSocket server2 = new ServerSocket(2002);
    ServerSocket server3 = new ServerSocket(2003);
    ServerSocket server4 = new ServerSocket(2004);
    I wonder how I can realize the fact that server1, server1, server3 or server4 is avalable?
    Please help me. Thank you.

    Maybe you misunderstood my question. Not in the slightest. I answered the question you asked.
    The fact is that you asked the wrong question. You asked about ports in use. You're now asking how to know if a Socket is active. That's a different question. A port is different from a socket, and they're both different from a connection.
    To answer that new question, Java provides Socket.isClosed(), Socket.isConnected(), etc.
    But note that all these APIs can do, in any language, is tell you what you have personally done with that Socket instance, in the current application. So actually these APIs are formally redundant: all they do is just maintain a few booleans recording what methods have been called. What they don't do, and can't do, in any language, is tell you about the state of the connection. Only reading or writing can do that.

  • HT201210 how could i restore like this but there is not working so please help me

    Hey friend. i always ask you how could i restore like this is ipad 2, 4 but there is not working so please help me. If you can hlep me then please sending me to my email. Email is [email protected]

    Post in your native language and provide details of what occurs when trying to update.
    You have yet to provide sufficient information for anyone to offer relevant assistance to resolve whatever issue is occurring.

  • I want to raise Credit note but Qty should not be reversed

    Hi All,
    i am raise A/R invoice qty 10 total amount 10,000, i want to raise a A/R Credit note for the same invoice but only deduct amount 1000 where the qty should not be reversed.
    Thanks & regards,
    Mobin

    Mobin,
    Instead of copying the invoice to a credit note, you can create a service type credit note in itself so you don't need to choose any items, just the amount.
    Regards,
    Nat

  • How to hide a tab? register tab should not apper after user logs in

    Hi,
    In our portal, we enabled self registration with custom registration page. We wrote a portlet for registraion and added registration page a tab on the portal page.
    But after a user registers and logs in, we don't want to show the registration tab.
    If you have any idea on this, please let me know.
    Thanks,
    Sasi Bhushan.

    Hi,
    After registration, users will be redirected to login page.
    When users log in with userid/password, we need to take them to the home page of the portal. In our case, we gave a tab for "home" just like we gave for registration.
    So, users should be on the home tab of the portal and now, users should not see registration tab.
    This is the requirement.
    Thanks,
    Sasi Bhushan

  • How to specify which Ethernet port on a Mac Pro to send an Ethernet packet

    Hi,
    I am doing some development on a Mac Pro. The Mac Pro has two Ethernet ports on the rear: Ethernet 1 and Ethernet 2.
    I want to specify which of these ports I send a UDP Ethernet packet from.
    In my code I currently create a socket and send data through this. This works fine, but the data (packet) always seems to come out of Ethernet port 1 on the rear of the Mac Pro.
    So, how / where do I set in my code which port (Ethernet 1 or Ethernet 2) on the back of the Mac Pro to send my packet out of?
    Cheers!
    SkinnyC

    It's ok, found this
    http://lists.apple.com/archives/macnetworkprog/2008/Feb/msg00070.html

  • HT1212 I am connecting the locked Iphodne as the direcctions say and turning it off then plugging it back to the usb port, but it is not "detecting a device to restore" what do I do now?

    I need help.  My daughtér's friend got on her iphone4s and plugged in the wrong passcode so now it's disabled.  I did as the directions say and turned the phone off while it is plugged into the usb port while turning it back on, but it doesn't say "detecting a disabled device reset"asit should.  What should I do?

    how long have you had your ipod? mine did the same but after a while you need to get a new one because of the battery...

Maybe you are looking for

  • Help needed with Photoshop plug-ins

    I am unable to access my plugins since upgrading to PS CC

  • 10g DB Installation on Windows

    Can you help me find 10g DB Installation on Windows instructions? Thanks in advance...

  • Canon Quick Menu has stopped working - Windows 8.1

    I get this message after I installed a new MG7500 series all-in-one. I have uninstalled the entire Canon package twice. This is what I found in the exception handler: Log Name: Application Source: .NET Runtime Date: 7/27/2015 10:40:45 AM Event ID: 10

  • LGBD390 blu-ray cannot find the access point of WRT160N/3.

    I have been trying to set up the wireless connection to be able to view streamed movies from netflix through my LGBD390 blu-ray player.  I have successfully connected the wireless router to my Embarq router.  When I check status, it says it is enable

  • No_data_found exeception

    Hi I have a procedure..Like CREATE OR REPLACE PROCEDURE Customer_Login ( in_web_login          IN      SLA_CUSTOMER_MASTER.WEB_LOGIN%TYPE,           --1 in_web_password       IN      SLA_CUSTOMER_MASTER.WEB_PASSWORD%TYPE,       --2 out_code_error