SocketChannel.close() can not close the pipes created.

In my project, i use SocketChannel.open() created a channel, when exception catched, i tryed to invok close() . but it looks unuse. Then, when i try to create new channels ,"too many open files" reported.
  package cn.com.westone.nioclient.test;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.List;
import cn.com.westone.nio.protocal.Protocal;
import cn.com.westone.nio.protocal.ProtocalSelector;
import cn.com.westone.nio.test.TestProtocal;
import cn.com.westone.nioclient.Notifier;
import cn.com.westone.nioclient.event.ClientListener;
public class TestChannels implements Runnable {
     private long param = 100;
     public TestChannels(long param) {
          this.param = param;
     public static void main(String args[]) {
          String args1 = args[0];
          long TestClientCount = 10;
          if (args1 != null) {
               TestClientCount = Long.parseLong(args1);
          Thread tThread = new Thread(new TestChannels(TestClientCount), "");
          tThread.start();
     public void run() {
          Notifier notifier = Notifier.getNotifier();
          ClientListener handlers = new EventClientImp();
          notifier.addListener(handlers);
          ProtocalSelector ps = new ProtocalSelector();
          List<Protocal> protocals = new ArrayList<Protocal>();
          protocals.add(new TestProtocal());
          ps.setProtocals(protocals);
          Selector selector = null;
          SocketChannel schannel = null;
          InetSocketAddress address = null;
          for (int i = 0; i < param; i++) {
               try {
                    selector = Selector.open();
                  schannel = SocketChannel.open();
                  schannel.socket().setReuseAddress(true);
                  schannel.socket().setSoLinger(true, 0);
                  schannel.configureBlocking(false);
                  address = new InetSocketAddress("127.0.0.1",8888);
                  schannel.register(selector, SelectionKey.OP_CONNECT|SelectionKey.OP_READ|SelectionKey.OP_WRITE);
                  schannel.connect(address);
                  while(!schannel.finishConnect());
                  Thread.sleep(100);
               } catch (Exception e) {
                    System.out.println("Error:" + e.getMessage());
                    try {
                         Thread.sleep(100);
                         schannel.close();
                    } catch (IOException e1) {
                         e1.printStackTrace();
                    } catch (InterruptedException e2) {
                         e.printStackTrace();
}can anyone help me? thanks

          while(!schannel.finishConnect());That's a stupid and wasteful way to connect. 100% CPU while the connection is completing. If you're going to block the thread like this why not connect in blocking mode?

Similar Messages

  • I can not customize the site created in Pagelets

    I can not customize the site in Pagelets created in Portal 9.0 any suggestions for solving this problem...

    Ok, I give more information:
    1.I user USER01 with this if I can customize (eg entry screen parameters, etc.) the Pagelets Portal Pack in the same Portal.
    2.I created a site on the Portal, with the same user can not customize any Pagelets Portal Pack on the site said.
    3.No shows me no screen, and crashes.
    This clearer idea ..., is understood now ...?

  • After rescue and recovery, I can not find the documents

    After rescue and recovery, I can not find the documents created after the restore point date.
    Moderator note: subject line adjusted for clarity.

    Hi,
    not sure, what exactly the description should tell me, but I guess, that your scenario is like this:
    - you captured some RnR backup
    - made some changes to the system
    - restored the backup
    and now the changes, that you have mde afte the backup was captured are gone.
    If this is your case, then this is a correct situation.
    The backup will restore the whole system back to the stage, as you selected, while it will remove/modify the packages, that have been changed/created  after the time, when the backup was captured.
    In the stage, where you have restored the system, you had the chance to save some files, but as it looks, this did not happened.
    Please correct me if I understod it wrongly.
    Cheers

  • Safari status bar disappears.  I have tried clicking on show status bar and it will only appear when I move the cursor to the top of the screen.  I can not minimize the open page only full screen or close the browser.  Any idea how the rectify this

    Safari status bar disappears. I have tried clicking on show status bar, under the View tab and it will only appear when I move the cursor to the top of the screen. I can not minimize the open page, only full screen or close the browser. Any idea how the rectify this issue?

    One enters and exits full-screen with control+command+F keys. This is on the View menu in Safari. Optionally, the green traffic light in your browser title bar, if you roll over it, has the full-screen control it it. While in full-screen mode with Safari, moving your mouse pointer virtually up, and off-screen reveals the Safari title bar again, and you can click the green traffic light to exit full-screen mode.
    You can hide/show the status bar by simply typing command+/. This too, is on the Safari View menu. and in 10.10.1 — it works reliably for me.

  • HT1349 before i do updates for my iphone(to 5.0.1) i close my SIM card, i can not complete the update proccess  becouse SIM is closed also i can not activate iPhone becous the SIM must be opened. when i try to open it , the networks does not appear (no se

    before i do updates for my iphone (to 5.0.1) i close my SIM card, i can not complete the update proccess  becouse SIM is closed also i can not  activate iPhone becouse the SIM must be opened. when i try to open it , the networks does not appear (no service).

    Its a serious problem and many people are facing the same issue on both locked and factory unlocked phones.
    I wonder when Apple will address to this issue. After all it is losing all its reputation!
    See this thread, many users are encountering the same issue:
    https://discussions.apple.com/thread/3425746?start=75&tstart=0
    I believe its a software issue and could be solved asap Apple fixes it!

  • I am trying to open iTunes on my Windows 7 PC and am getting the following message...the itunes library can not be found or created.  The default location for this file is in the "iTunes" folder in the "Music" folder.  Any ideas?

    I am trying to open iTunes on my Windows 7 PC and am getting the following message...the itunes library can not be found or created.  The default location for this file is in the "iTunes" folder in the "Music" folder.  Any ideas?

    Let's try this first. Hold down the Shift key while you try to launch iTunes. You should eventually see the following dialog:
    Click "Choose library". Browse to inside the following location (depending on what operating system you're running):
    Operating System
    Default location of iTunes library
    Microsoft Windows XP
    \Documents and Settings\[your username]\My Documents\My Music\iTunes\
    Microsoft Windows Vista
    \Users\[your username]\Music\iTunes\
    Microsoft Windows 7
    \Users\[your username]\My Music\iTunes\
    ... and open the iTunes library you find in there.

  • HT5787 My apple id has been hacked. hacker has changed all information in the apple id so I can not change the password. Account information from the apple id created is still in my mail. How do I regain apple id. Thanks

    My apple id has been hacked. hacker has changed all information in the apple id so I can not change the password. Account information from the apple id created is still in my mail. How do I regain apple id. Thanks

    Contact Apple support: Apple ID: Contacting Apple for help with Apple ID account security

  • I installed CS6 on Mac Pro (10.9 software version). I don't see the Adobe PDF printer in the printer/fax section.  I can not figure how to create the PDF Printer.

    I can not figure how to create a Adobe PDF Printer. Normally when you install the package ( CS6 Standard for Mac Pro) the installer creates the PDF printer automatically. In the System Preferences under the Printer/Fax I don't see the PDF printer. How do you create the PDF printer.
    Thanks,
    Melanie

    did you install acrobat x and does it work as expected?

  • The folder "itunes"can not be found or created and is required

    I am getting this error message when I try to open Itunes on my pc. The error message reads:
    The folder "itunes" can not be found or created and is required. The default location for this folder is in "my music" folder.
    I can see it there and I open it and hit agree to contract and this error message come up. I have deleted the program reinstalled the program. Please if you have any suggestions on how to fix this I would appreciate the help.
    Thanks Mkitz

    the best place to start with that one is with the following document:
    iTunes for Windows: "Disk is locked" or "iTunes folder cannot be found" when installing or opening iTunes
    ... but if you run into the complication where "My Music" doesn't appear as an option in TweakUI, perhaps try the alternate procedure from the following Nigel Carpenter post:
    Nigel Carpenter: re: Itunes problem

  • I'm having trouble with custom ringtones.  I have downloaded the free software "makeTones" and have created some ringtones.  I then copied those to Mac and played them in ITunes.  My Itunes does not have a ringtone tab.  I can not sync the ringtones.

    I'm having trouble with custom ringtones.  I have downloaded the free software "makeTones" and have created some ringtones.  I then copied those to Mac and played them in ITunes.  My Itunes library does not have a ringtones tab.  I can not sync the ringtones (or I don't know how)!  Please help.

    Yes, the file extension is M4R.  Does it matter where I save these files on my Macbook?  I then opened them in Itunes and played them.  I did find the Tones folder in Itunes but the Tones or Ringtones tab does not show up when I select Iphone (within Itunes).  When I open the Tones folder in the Library, it is empty.  Thanks in advance for your help.

  • "The folder "iTunes" can not be found or created, and is required. The defa

    Hi all,
    I am using a 80GB ipod classic for some time now. I recently bought a new hard drive and am in the process of repopulating my files. My problem is with this error message, "The folder "iTunes" can not be found or created, and is required. The default location for this folder is inside the "My Music folder."
    My old hard drive is intact but when I place the My Music/iTunes file on to the hew hard drive I get the same message over and over. I have Googled the heck out of this one to no avail. I have tried many approaches to this issue and am beyond aggravation. Am I simply to accept that 42GB of music is gone? Or that I have to revert to my old hard drive just for iTunes...
    Thank you...

    Hello, Welcome to Apple Discussions.
    You may wish to try
    iTunes for Windows XP: "Disk is locked" or "iTunes folder cannot be found" when installing or opening iTunes
    http://support.apple.com/kb/HT1866?viewlocale=en_US

  • HT201317 I created a folder in my photostream on my iphone but I can not see the folder on my iPad 1.  My wife does see the folder on her iPad 3.  Is there anything I can do for my older iPad?

    I created a folder in my photostream on my iphone but I can not see the folder on my iPad 1.  My wife does see the folder on her iPad 3.  Is there anything I can do for my older iPad?

    If you created an album containing some of your photo stream photos, this will not be shared using photo stream.  If you want to share a subset of your photos, create a shared photo stream and share it with your wife, as explained here: http://help.apple.com/icloud/#mmc0cd7e99.

  • HT4484 i used to have an app store and lost it and i created a new one and i can not update the iphoto app because it was updated with the old account, is there a solution for this problem?

    i used to have an app store and lost it and i created a new one and i can not update the iphoto app on my macbook pro because it was updated with the old account, is there a solution for this problem?

    Content and Apple IDs -
    Content is forever tied to the Apple ID that bought it. Apple does not transfer content from one Apple ID to another. Apple does not merge Apple IDs. You will never be able to access your content bought with one Apple ID with a new Apple ID.

  • I created a partition on my iMac drive. I have trashed the files that were in the partition but I can not trash the icon. I tried with Disk Utility. Any ideas?

    I created a partition on my iMac drive. I have trashed the files that were in the partition but I can not trash the icon. I tried with Disk Utility. Any ideas?

    If I understand correctly,  the partition will still be on the disk and therefore mounted on the desktop. You would need to remove that partition to remove the icon.
    Be careful if you try this, don't upset the main Macintosh HD partition or you may lose the OS and your files.
    And always have a full tested backup of your system before modifing disk partitions.

  • Why I can not view the CMP bean created tables in cloudscape?

    Hi:
    I have deploy a CMP entity bean which will automatic create a table named ToolBeanTable.
    I can find the table exist in cloudscape and its structure thought JDBC tool.
    But I can not view the data, the error is said that the table is not existed.
    Why?
    Thanks!
    John Lee

    Hello,
    I also had the same problem when I am using Microsoft SQL Server Management Studio 2012. I created a new table.  When I select * from mytable, it can execute and I can see the table in the results part, but I can localize the table in left part "database"
    menu. Actually, I suspect there is something missing in the Databases folder. When I am using SQL management studio in another machine, I can see a folder called tables under Database, which hold all the newly created tables. But I could not find it here.
    On bottom, it may indicate the table is in "master" folder, but I can not find it either. Within "master" folder, there are "Views", "Synonyms", "Programmability", "Service Broker", "Storage", "Security" I already refreshed the Databases folder several times.
    Can anyone kindly help me?
    Thanks,
    Feifei

Maybe you are looking for

  • Exclusive Free Goods

    Dear Experts, In transaction VBN1, is there anyway where I can set "Exclusive" and Calculation type "2" as default. This is to prevent the users from accidentally maintaining "Inclusive" free goods. Thanks in advance!

  • How I add a LIBRARY ITEM to a page layout, top/bottom ?

    how I add a LIBRARY ITEM to a page layout, top/bottom ? in dwmr mx 2004 and cs4 ?

  • Continuation of line item data to next page in SmartForm

    Hi, Currently i had a requirement in SmartForm. Iam displaying the line items from bseg table in main window and totals of credit and debit in the total window which comes under the main window. If the line items are more and it continues to next pag

  • Need help saving Workspace layout

    At Photoshop World, Julieanne Kost mentioned that she likes to have all of her panels to the left. I tried this at home and really like it like that, so I saved a new workspace. My problem is that when I open a new image, the image window floats behi

  • Envelope Distortion help?

    I am trying to make an envelope with 2 objects. One is a symbol set of circles, and another is a patch of stars. every time I try to make the envelope, it keeps saying that there needs to be a single path, I'm assuming that means the circles need to