How to resolve the possibility of losing data of NIO programming

I have a peer to peer application, in each side, there's two thread, one (thread A) accepting new connection from according peer and receiveng data, the other (Thread B)create a connection to peer, send message and close the connection.
such scenario will occur:
1. [thread B] create a SocketChannel and connect to peer, and register to A.selector
2. [thread B] send a request to peer
3. peer send response back
3. [thread B] close SocketChannel
4. [thread A] select
so when thread A run Selector.select(), the SocketChannel has been unregistered from the selector because it has been closed, so A can not get the response.
How to resolve this problem, thanks!

Looking a bit more carefully at your example
Why are you closing the channel after you send if you intend to read more from it? You should only close when you are done both sending and receiving.
Also this example appears simple enough to do without using Selectors, and if do use them you don't need multiple threads.

Similar Messages

  • Is it possible to resize the partitions without losing data?

    I have following issue:
    I have dual-boot Arch with Windows XP. I created 4 partitions: 40GB XP's system disk (ntfs), 80GB ntfs data disk, 1GB swap and 25GB Linux partition.
    But I am running XP so rarely, that it is frustrating, that I have most of my data on ntfs partition... I'd like to wipe out that 80GB ntfs, resize the system ntfs partition up to for example 60GB, and add the remaining 60GB to my linux ext3 partition (because I'm running out of free space recently...).
    Has anyone done something like this, and how safe it is (if possible at all)
    Yes, I have read this: http://wiki.archlinux.org/index.php/Res … _partition, and a few more.
    I just don't have time to reinstall both systems (especially I would not like to install Windows, because I'd rather install Vista from my recovery disk, than hack the XP to work again...), and if some issues are likely to appear, then I'll give it up for now .

    It's trivial using gparted, but as with any similar operation, you run the risk of losing data - so you'd better backup.

  • I have recently purchased the highest storage but was unable to backup my phone via icloud, the button on my mphone to backup on icloud is grey out, anyone knows how to resolve the problem?  What's the point of purchasing the biggest storage?

    i have recently purchased the highest storage but was unable to backup my phone via icloud, the button on my iphone to backup on icloud is grey out, anyone knows how to resolve the problem?  What's the point of purchasing the biggest storage?

    First check that your device is correctly connected to the wifi/internet (settings > wifi)
    If your back up continually fails, you might try turning off back up on your mobile device (settings > iCloud > storage & backup) and then deleting the backup file from iCloud by swiping the backup file on the mobile device (settings > iCloud > storage & backup > manage…) and then turning back up on again.
    If this doesn't help, try turning off some items for back up in a pattern to try to establish if your problem is being caused by specific data on your device.
    Being able to back up to the cloud can be very useful, especially if you don't have access to a computer or have infrequent access to one, however unless you specifically need to use iCloud for back up, you will find backing up to iTunes significantly more convenient and possibly more reliable.
    More about iCloud v iTunes Back Up

  • My iPhone 5 has broken and is being replaced with a new iPhone tomorrow. However, My carrier (orange) will b picking up my broken iPhone and I am unsure how to secure the content and icloud data on the broken phone. Is there a way to display the data?

    My iPhone 5 has broken and is being replaced with a new iPhone tomorrow. However, My carrier (orange) will b picking up my broken iPhone and I am unsure how to secure the content and icloud data on the broken phone. Is there a way to disable the data held on it and ensure that if it is fixed, nobody can use/see my data and access my account?

    Hi Gazpan,
    Thanks for visiting Apple Support Communities.
    I recommend using the steps in this article to back up your iPhone if possible:
    iOS: Back up and restore your iOS device with iCloud or iTunes
    http://support.apple.com/kb/ht1766
    You may also find this advice helpful for your situation:
    What to do before selling or giving away your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/ht5661
    If you no longer have your iOS device
    If you're using iCloud and Find My iPhone on the device, you can erase the device remotely and remove it from your account by signing in to icloud.com/find, selecting the device, and clicking Erase. When the device has been erased, click Remove from Account.
    If you're unable to complete either of the above steps, you should change your Apple ID password. Changing your password won't remove any personal information that is cached on the device, but it will make sure that the new owner can't delete your information from iCloud.
    Cheers,
    Jeremy

  • How to download the ALV Hierchial Tree Data to an Excel sheet.

    Hi All,
    Can any body please let me ,if there is any possibility to know How to download the ALV Hierchial Tree Data to an Excel sheet.
    If yes, please let me know how could this can b acheived.
    Regards,
    Rohini.

    Hi Rohini
    There is no such functionality provided by SAP to download ALV Tree Hierarichal Tree into excel sheet .
    If you had this kind of senario then i can propose one solution create two radio buttons one is to display in ALV Tree Format and the other is classical report which you can download it for futher process
    Regards
    Hitesh Batra

  • After the IOS 7.1 update I have issue with Game Center, I'm not been able to  load the  games. The apps don't seems to be able to connect to game centre. How to resolve the issue?

    After the IOS 7.1 update I have issue with Game Center, I'm not been able to  load the  games. The apps don't seems to be able to connect to game centre. How to resolve the issue?

    Try reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • I am transmitting data over internet and WiFi ,it's working fine with internet but when I choose WiFi for data transmission data is not being transmitted. What may be the possible issues of data transmission failure over WiFi?  Please help me.

    I am transmitting data over internet and WiFi ,it's working fine with Internet but when I choose WiFi for data transmission data is not being transmitted. What may be the possible issues of data transmission failure over WiFi?     Please help me....
    Thanks in Advance.
    Neeraj@iDev

    After a week's worth of debugging, I found the issue.
    The Java type returned from the call was defined as ArrayList.  Changing it to List resolved the problem.
    I'm not sure why ArrayList isn't a valid return type, I've been looking at the Adobe docs, and still can't see why this isn't valid.  And, why it works in Debug mode and not in Release build is even stranger.  Maybe someone can shed some light on the logic here to me.

  • I got my iPhone disabled mistakenly by six trials of entering pass code. However now I remembered  my passcode so how can fix the problem without losing my contents.

    I got my iPhone disabled mistakenly by six trials of entering pass code. However now I remembered  my passcode so how can fix the problem without losing my contents.

    If your phone is now disabled, you've already lost all data on the phone...that's the whole point of the passcode, to protect the data on the phone. Your only choice now is to force the phone into recovery mode & restore it, as described here:
    http://support.apple.com/kb/ht1212
    This will remove the passcode, but also erase all data on the phone unless you have a backup to restore from.

  • How to find the table in which data from a structure sits

    Hi,
    I want to know how to find the exact table where data sitting in various structures during runtime are stored.
    For instance,in ME23N we have various tabs and data in those are held in various structures. This we can see by checking the technical setting of each field.
    I want to know in which table the data is actually stored for each field and how to find them.
    Any other means other than using "WHERE USED" option?
    Thanks
    CM

    After checking for technical field from the screen, when you reach out to structure, you can dbl click on the particular field's data element. From this data-element you can get to know in which tables it is used. Also if the data element refers to some master data field then you can check out its domain and in the domain you can refer the<b> value table</b> for that domain. This is what i will do if i am not sure about anything.
    Hope it will help a little.
    Jignesh.

  • TS1702 Does anyone know how to resolve the problem of apps not being able to download in the App Store? After the IOS 6 update I haven't been able to download any apps.

    Does anyone know how to resolve the problem of apps not being able to download in the App Store? After the IOS 6 update I haven't been able to download any apps.

    Maybe here:
    IOS 6 App store crash: Apple Support Communities

  • I-photo:  I used 2 cameras to take pictures on a trip --- i have put the pictures from both cameras into an album --- when i click on view and then sort by date, the pictures do not sort by date --- any ideas on how to get the pics sorted by date?

    I-photo:  I used 2 cameras to take pictures on a trip --- i have put the pictures from both cameras into an album --- when i click on view and then sort by date, the pictures do not sort by date --- any ideas on how to get the pics sorted by date?

    Select all the photos that you need to change, then click the "Photos" menu and choose "Adjust Date and Time".
    If you add a year, it will adjust all the photos that you selected by adding a year (so if you accidentally select one of the photos that already has "2012", that will change to "2013"). 

  • I have started to get this error message: 5.1.3 bad address syntax in my email account. I am using Outlook 2011. It does not appear to be affecting sending or receiving email. I have no idea what it means or how to resolve the issue. Any advice?

    I have started to get this error message: "5.1.3 bad address syntax" in my email account. I am using Outlook 2011. It does not appear to be affecting sending or receiving email. I have no idea what it means or how to resolve the issue. Any advice?  My email account is through Optimum online and I am using Airpost Express.
    P.S. The error sound "bong" is driving us nuts!

    Please post on the Office for Mac product forums that Microsoft hosts. It's their product and they can best troubleshoot the issue.

  • How to resolve the problem in jdeveloper903 oc4j starting:JspTagLib listener error

    I just download a jdeveloper903,i hava a problem:
    when i start the oc4j alone,it prompt "JspTagLib listener error:null". Then,After depoly the jsp application with JspTag to oc4j,I found the jsp page can not run,but,the jsp application can run in the
    develope environment.
    how can resolve the problem,help!!Thanks.

    I think you might have better luck asking your question in the JDeveloper forum at:
    http://forums.oracle.com/forums/forum.jsp?id=315684
    later -- Jeff

  • How to get the difference of two dates in years,months and days

    Hi friends,
    how to get the difference of two dates in years,months and days
    for ex 2 years 3 months 13 days
    select (sysdate-date_Start) from per_periods_of_service
    thanks

    Something like this...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select to_date('17-nov-2006','dd-mon-yyyy') as c_start_date, to_date('21-jan-2008','dd-mon-yyyy') as c_end_date from dual union all
      2             select to_date('21-nov-2006','dd-mon-yyyy'), to_date('17-feb-2008','dd-mon-yyyy') from dual union all
      3             select to_date('21-jun-2006','dd-mon-yyyy'), to_date('17-jul-2008','dd-mon-yyyy') from dual
      4             )
      5  -- end of test data
      6  select c_start_date, c_end_date
      7        ,trunc(months_between(c_end_date, c_start_date) / 12) as yrs
      8        ,trunc(mod(months_between(c_end_date, c_start_date), 12)) as mnths
      9        ,trunc(c_end_date - add_months(c_start_date, trunc(months_between(c_end_date, c_start_date)))) as dys
    10* from t
    SQL> /
    C_START_D C_END_DAT        YRS      MNTHS        DYS
    17-NOV-06 21-JAN-08          1          2          4
    21-NOV-06 17-FEB-08          1          2         27
    21-JUN-06 17-JUL-08          2          0         26
    SQL>But, don't forget that different months have different numbers of days, and leap years can effect it too.

  • How to get the name of a Data Element of a generic Table!

    Hi guys!
    In my function i have the following import paramenter
    i_outtab type standard table
    now i import a table and i want to get the dataelement of the fields.
    is there a way to do this??

    Hello Thomas
    Perhaps the following sample report may be useful for you.
    *& Report  ZUS_SDN_RTTI_STRUCT_COMPONENTS
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1145711"></a>
    *& Thread: How to get the name of a Data Element of a generic Table!
    REPORT  zus_sdn_rtti_struct_components.
    TYPE-POOLS: abap.
    TYPES: BEGIN OF ty_s_outtab.
    TYPES: bukrs    TYPE bukrs.
    TYPES: kunnr    TYPE kunnr.
    TYPES: END OF ty_s_outtab.
    DATA: gdo_data    TYPE REF TO data.
    DATA: gs_outtab   TYPE ty_s_outtab.
    DATA: go_typedescr  TYPE REF TO cl_abap_typedescr,
          go_structdescr  TYPE REF TO cl_abap_structdescr,
          go_datadescr    type ref to cl_abap_datadescr.
    DATA: gs_comp        TYPE abap_compdescr,
          gd_dtel        type string,
          gt_dfies        type ddfields.
    FIELD-SYMBOLS:
      <gs_struct> TYPE ANY.
    START-OF-SELECTION.
      BREAK-POINT.
      GET REFERENCE OF gs_outtab INTO gdo_data.
      ASSIGN gdo_data->* TO <gs_struct>.
      go_typedescr = cl_abap_typedescr=>describe_by_data( <gs_struct> ).
      go_structdescr ?= go_typedescr.
      BREAK-POINT.
      LOOP AT go_structdescr->components INTO gs_comp.
        go_datadescr = GO_STRUCTDESCR->GET_COMPONENT_TYPE( gs_comp-name ).
        gd_dtel = go_datadescr->get_relative_name( ).
        write: / syst-tabix, 'Data element =', gd_dtel.
      ENDLOOP.
    END-OF-SELECTION.
    Regards
      Uwe

Maybe you are looking for

  • EEWB - In BP, adding a new field regenerates append structure

    Hello, After adding or deleting a field using EEWB, I have the following issues - 1. The new append structure that was created for BUT000 gets regenerated 2. Field labels get overwritten by field names 3. The order in which the fields were seen on th

  • Can't get SQL 2008 Express installed

    Hope some one can help me. I am trying to install 2008 Express version and I constantly get the following error. I have tried pretty much all flavors of express and get the same thing. I uninstalled several time and reinstall but keep getting the sam

  • App store billing issue (prob not the right place for this but i couldn't find a better one)

    I have been using the same card for my itunes account for as long as i have had an itunes account and a personal credit card, all of a sudden about a week or so ago while trying to update some applications on my iphone it asked me to sign in and conf

  • What to Deinterlace

    I'll start with my workflow, Im shooting DVCAM and HDV PAL and using FCP5, once my project is built i send MP4's via email to a website builder, burn DVD's as hard copies and dub the created sequence back to tape for storage or sometimes broadcast. S

  • Power Book doesn't receive airport nor ethernet signal

    OK, so I recently did an erase and install on my powerbook g4 from the original start-up disk. Then, I immediately updated to OSX 10.4.3 from my Tiger DVD. Now, my laptop won't pick up a signal from the airport. Internet Connect status says "not asso