[NSFileHandle][Sockets] How to manage a network disconnection?

Hi,
I have built a client/server app that communicates via TCP/IP.
The *Client is an iPhone Application* that receives and sends many messages of variable sizes through a NSFileHandle object linked with a socket as its filedescriptor
I catch *incoming bytes trough an Observer* whose matching message is named "DataAvailable:(NSNotification *)aNotification".
*When the server stops*, the observer receives one last "dataAvailable" notification, which I try to manage with the [NSFileHandle readdataoflength:1]... that throws an *exception indicating the +connection has been reset by peer+* , which I catch and manage through a SocketDidDisconnect: homemade message.
But I have a *problem when the disconnection occurs directly because of a network disconnection* (I did disconnect the network on purpose) : I receive *no "DataAvailable" notification* (although it receive one I just close the connection from the server Application).
Then I thought I could check every 1/10 seconds if my connection was still ok by trying to do a [MyNSFileHandle ReadDataOfLength:0] : that would throw an exception as soon as my connection goes down. But obviously, reading 0 bytes does not have any effect. And since I don't wanna loose the queued incoming data by various random reading, I don't know how to detect such a network problem.
If any of your has an idea about *how to manage a network disconnection with a NSFileHandle without involving the random reading of queued incoming data*, I will listen to you with the greatest interest.
Thank you for reading till the end.

Looks like it will be of some help, yes.
But I don't have time to test it today. I'll tell you as soon as I have tested it.
Thanks anywa for your help

Similar Messages

  • How to manage socket communications

    i need to learn about how to manage socket communications. does any one has sample codes to share that illustrates how to manage sockets? Im going to create an application that listens over a socket. My socket listener should be able to read over the socket continuously without user intervention. If there's no data, it would wait until something comes in. If some data come in, the listener should be able to read it automatically, and save data in db.
    Im thinking of an infinite loop here, but the problem
    arises when the socket is waiting for data to come in. The application consumes 100% CPU resources. And im only running one instance of my socket listener. My solution here is to use threads and let the thread SLEEP for a while when no there's no data yet.
    Any advise on this matter is very much appreciated. Thank you.

    It sounds, that you are using non-blocking read from a socket inside a busy wait loop. You should do a blocking read, which means your process/thread will be suspended by OS untill something is available on your socket.
    I'm new to Java and I can not say how actually to implement this, but look for "blocking/non-blocking read" in network interface documentation.
    Zhenya.

  • How to manage streaming in different networks??........

    hi,
    can anyone tell me about how to manage one-one streaming thru different networks?.... For eg:- in a LAN connection, suppose 2 machines have ip's 192.168.0.1 and 192.168.0.153. but when the first machine is connected to internet, it's ip changes to say, 220.56.0.89. But the second machine even if it has internet facility , it's ip is still 192.168.0.153. how can i get the global IP of the second machine?
    or,
    How can i send/receive streams between these two??......

    Backup to what where??
    Do you mean backup to your TC sitting at home? Apple recommends you do not do it. It is too easy to corrupt and the speeds are too slow unless you have high speed fibre at both locations.
    Do you mean cloud? Yes, you can probably backup your files to the cloud but you will need to pay for the extra storage and it is still very slow due to upload speed being a fraction of download.

  • How to Fire ondisconnect event when network disconnect suddenly

    Hello Friends
                          can any body tell me how to clear the client entry from Adobe flash Media server 3.5. when net disconnect.
    i was expecting that on netdisconnect from the client side end(which is connected to FMS) its onDisconnect event fire similarly as it fire for browser close.But when internet disconnect  ondisconnect event not fires at FMS side is there any way to overcome this or any other event  fire at that stage?
    if it is possible to get any event on network disconnection at client sidetahn i can solve the issue.
    Thanks and Regards
       Vineet osho

    You  must be getting the "NetConnection.Connect.Closed" as info.code in the onStatus for the NetConnection.
    See http://livedocs.adobe.com/fms/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDoc s_Parts&file=00000742.html
    nc = new NetConnection();
    nc.onStatus = function(info){
        if (info.code == "NetConnection.Connect.Closed")
            // Netconnection has closed.

  • Windows 8 - Manage Wireless Networks?

    Where is the Control Panel in Windows 8 for Manage Wireless Networks? I want to work with my wireless profiles.
    Thanks

    They won't let me post a link here as they claim my account hasn't been verified.  I found this on a Microsoft webpage by doing a Google search for Manage Wireless Network Profiles Applies to Windows 8.1
    Manage wireless network profiles
    Applies to Windows 8.1, Windows RT 8.1
    If you need to change a wireless connection profile, you can usually do it by following these steps:
    1.  Swipe in from the right edge of the screen, tap Settings, and then tap Change PC settings.
    (If you're using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, click Settings, and then click Change PC settings.)
    2.  Tap or click Network, tap or click Connections, and then tap or click the connection you want to change.
    3.  On the page that appears, make the changes you want.
    Some tasks, such as deleting a profile, must be done at the command prompt. To do these tasks, open Command Prompt, and then type the appropriate command from the following table.
    Open Command Prompt by swiping in from the right edge of the screen, tapping Search (or if you're using a mouse, pointing to the upper-right corner of the screen, moving the mouse pointer down, and then clicking Search), entering Command Prompt in the search
    box, and then tapping or clicking Command Prompt.
    Task
    Instructions
    Delete a profile
    At the command prompt, type:
    netsh wlan delete profile name="ProfileName"
    Show all wireless profiles on the PC
    At the command prompt, type:
    netsh wlan show profiles
    Show a security key
    At the command prompt, type:
    netsh wlan show profile name="ProfileName" key=clear
    Move a network up in the priority list
    Connecting to a new network and choosing Connect automatically will place it at the top of the list.
    Stop automatically connecting to a network within range
    Tap or click the network in the network list, and then click Disconnect.
    Stop automatically connecting to a network that's out of range
    At the command prompt, type:
    netsh wlan set profileparameter name="ProfileName" connectionmode=manual
    How Windows determines connection priority
    Windows usually connects to networks in this order:
    1. Ethernet
    2. Wi-Fi
    3. Mobile broadband
    When you connect to a new Wi-Fi network, it’s added to the list, and Windows will connect to that network while it’s in range. If you connect to another Wi-Fi network while in range of the first network, Windows will prefer the
    second network over the first one.
    Mobile broadband networks are treated differently. If you manually connect to a mobile broadband network when there is a Wi-Fi network in range, the mobile broadband network is preferred just for that session. The next time you’re in range of
    both networks, the Wi-Fi network is preferred. This is because mobile broadband networks typically are metered.
    If you want to force your PC to prefer a mobile broadband network over Wi-Fi, tap or click the Wi-Fi network in the list of networks, and then click Disconnect. Windows won’t automatically connect to that Wi-Fi network.

  • Could not create shortcut Manage Virtual Networks.lnk during VM Server 2 install. Why?

    I am trying to install VMware Server 2.0.2 on my HP Laptop running Windows 8 Pro as Host. But I am getting the following warning messages but the install continues to completion:
    Warning Msg:
    Warning 1909. Could not create shortcut Manage Virtual Networks.lnk. Verify that the destination folder exist and that you can access it.
    Warning 1909. Could not create shortcut Server Home Page.lnk.         Verify that the destination folder exist and that you can access it.
    After installation, I am not able to login to the VM Server. When I click on the VMware Sever login icon, the error that I am getting states: okonita1:8333 -
    Oops! Page Not Found
    Sorry, the page you were looking for could not be found.
    I am at a loss how to correct this error. I have googled, read and followed a lot of the online help that I can find including taking ownership of suspect target folders such as ProgramData, all to no avail.
    At this point, I am hoping someone does know what specifically can help resolve my issue and I am asking for help. VMware knowledge base or support are not helpful.
    Thanks all,
    Enyi

    Did you run the VMServer setup *as Administrator*?
    Did you have IIS installed on your system before you installed VMServer?

  • How to Make Wirless Network SECURE

    I am running my desktop hard line to a comcast modem which runs XP Pro. My Laptop which is running Vista is set up wireless via the WRT54GS Linksys Router.
    The wireless network is running great but it is identified as UNSECURED!
    After three 30 minute waits last night, 2 disconnects when I was not understanding them ( not a computer whiz but I do ok) and 1 live chat tech that copy and pasted the directions on how to set it up but not how to make it secure and then a quick disconnect    .
    Can anyone tell me exactly HOW TO MAKE THIS NETWORK SECURED and WHAT computer shall I use to perform this?
    Thank you for any help you can give me,
    SWAT
    JohnDoe sorry for violating any rules.
    (Edited post for guideline compliance. Thanks!)
    Message Edited by JOHNDOE_06 on 08-27-2007 11:04 AM
    Message Edited by SWAT on 08-27-2007 11:13 AM

    SWAT wrote:
    Sbatch...you click on the pull down window to the settings.....I click on WPA then I input the code I wanted (only room for 1 code) then scroll all the way down to click on save settings.
    That method does not secure my laptop wireless settings?
    **No, that secures your router's wireless settings.
    or
    Is this the only method to secure the network?
    With some investigation I can find have found the following:
    If I right click on my Network Icon in my tool bar and then click Connect to Network and then right click on the Network and right click Properties I get a box with the following:
    Tab for connection and a tab for security with pull down bars which can be changed...
    1) Security Types -No Authentication (open), shared, wpa2 personal, wpa personal, wpa2 enterprise, wpa enterprise and 802.1x
    2) Encryption Types -WEP
    Current settings on my laptop Linksys wireless network security is
    Security Type- OPEN
    Encryption- NONE
    sBatch when I perform the WPA on my desktop my laptop must be off or not on the network correct?
    Doesn't matter, once you change the security settings onthe router, you will be prompted for the settings to reconnect to it.
    Has anyone found the LinkSys hyperlink for setting the WRT54GS router as SECURED?
    Define "secured".  Wired, only physical connection have access.
    Wireless, once you add WPA or WEP (WPA is better) it's secured.
    Sincerely,
    SWAT
    Does that help?

  • How to Identify the Network Topology being used for a running ForeFront TMG Stand Alone array?

    Hello Experts,
    My client has decided to move their datacenter  from one location to other including the ForeFront TMG servers which are being used as Reverse Proxy and TMG Gateway  in DMZ environment.
    I need to know the network topology used for this configuration so that I could chose the same topology when creating new TMG environment at new datacenter. Here are some details : 
    1. There are 2 TMG servers configured in a DMZ Workgroup in Stand Alone array.
    2. Both servers have 3 NIC attached to them. (one has all public IPs configured, another one has internal IP address and the third one has Management IP which is used to connect the server via RDP).
    3. There are more than 50 websites published via this standalone array.
    I am very new to Forefront TMG technology and need to know the Topology used to create such environment.
    Thanks 
    Lalit

    Hi,
    According to your description, you can use the 3-leg perimeter network template and choose which network adapter connects to the LAN, which network adapter connects to the external  network and which network adapter connects to the DMZ.
    Did you set up TCP/IP settings for the three NICs? If not, please refer to the link below:
    Recommended Network Adapter Configuration for Forefront TMG Enterprise Edition Servers
    More information:
    Microsoft Forefront TMG – How to use TMG network templates (Note:
    Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.)
    Best regards,
    Susie

  • How to manage VPN clients in SCCM 2012

    Hi,
    In my environment, I have multiple clients over VPN in multiple sites, 
    now I have problem, I how can I manage those clients for VPN, coz n CM 2012 I have to give boundary group and n boundary group  have to give the site server references, and I have only one IP subnet in whole environment, but from that subnet, some clients
    are from A site, B site and C site, now can you tell me how to manage them, 
    How to configure DP for them??
    How they can get correct MP?  
    Sharad Singh | My blogs: SharadTech | Twitter:
    @SinghSharaad | | Please remember to click “Mark as Answer” on the post that helps you.This can be beneficial to other community members reading the thread.

    Jason, 
    I have only one IP subnet means I have only one IP subnet for VPN clients n all environment, all clients from all sites which are connecting with VPN they will fall on that VPN IP subnet.
    other than  have LAN/WAN link for all sites, which I have already configured according to Sites/DP and there s no problem, every thing is working fine.
    but for VPN i have only one network which is worldwide, and that network used by all sites, this is the problem, How can I manage that network, and where should I add for boundary/DP for site references??? 
    Sharad Singh | My blogs: SharadTech | Twitter:
    @SinghSharaad | | Please remember to click “Mark as Answer” on the post that helps you.This can be beneficial to other community members reading the thread.

  • How to manage sequence number in PLD but not use LineNum()?

    Hi,All
    I want to show number in PLD.
    Probem, I can't use LineNum() because in some row in matrix that no price i will not show data.
    Now,if i use LineNum() when i print preview in column system will skip record that no have price.
    How to manage for get number order ascending sequence ?
    thank you
    Message was edited by: Frank Moebius

    Hi,
    Unfortunately I am not an expert in this area.
    I hope someone else can help you out though!
    However, I would like to draw your attention to the fact that the main purpose of this forum is around the SAP Business One SDK - and so appears to be the main expertise of the people participating here...
    ...this might be one of the reasons why it happens that you don't get an answer top your posts sometimes...
    Therefore I would like to advise you to use the "Implementation" Forum in the CPSN (Channel Partners Solution Network) to ask your questions.
    I hope you get more answers there + quicker.
    Sorry & Thanks for understanding,
    Frank

  • How to manage Rescue and Recovery Backups

    Hi I've been using disk image backup solutions since the days of powerquests Drive Image. And have had my days with Ghost and Acronis Trueimage. I recently built a clean Vista image on my T400, and I'd like to take advantage of the Lenovo Rescue and Recovery 4.21 tool since it the recovery technology is already part of my system and I have tested it once.
    I'm used to the idea that a backup tool will produce an image file, which I can manage myself, moving to various media....hiding under my bed etc. With RnR, I've noticed it prefers to control the directory's where backups are placed (this is a bit annoying to me, but I can live with it, as long as it's isolated to the RRBackup directory - which it appears may not be the case). I do appreciate it's ability to specify various backup media locations (network, CD, 2nd HDD, USB) and recognize that it's a simple approach for basic usage.
    Recently I've backed up my image to USB drive, and also to the local disk. I'd like to take that back up and split it up into DVD's and burn it to disk. I know there is a built in RnR feature which lets us copy backups from the local drive (why only local drive ??) to USB/Network/CD, but unfortunately the CD copy feature burns directly to my thinkpad burner...which is a CDR device, not a DVDR device. I'd like to use the DVDR device on my desktop...
    Anyway, I'd like to know if there is more resources on how to manage RnR Backups. I found the following guide http://www-307.ibm.com/pc/support/site.wss/MIGR-70344.html (which is hard to get on Lenovo's site...google finds it better), I'm still reading it, but so far it appears more focused on the pre-desktop area than backup management.
    Any insight would be appreciated.
    Thanks!

    Hi Danielle,
    Consider this allegory; factory settings will make your thinkpad like a never driven 0 meter car [with reference to software]. Hence it will be far-flung from it's previous state. Apart from what you have already saved on memory stick, all settings and the software you have installed on the notebook will be lost.
    I hope this helps.
    Maliha (I don't work for lenovo)
    ThinkPads:- T400[Win 7], T60[Win 7], IBM 240[Win XP]
    IdeaPad: U350
    Apple:- Macbook Air [Snow Leopard]
    Did someone help you today? Compliment them with a Kudos!
    Was your question answered today? Mark it as an Accepted Solution! 
      Lenovo Deutsche Community     Lenovo Comunidad en Español 
    Visit my YouTube Channel

  • How to manage my media

    Hi all
    I need some advice please on how to manage my media between my original laptop which has all my current media on, and my new mac mini.
    Some background....I got the mac mini mainly to use with my LCD TV and front row listening at home and viewing pics on a big screen.
    So starting with music, im confused as to the best approach to take. I have an iPod and want to maintain my play counts and ratings as these drive my playlists. If i transfer my current metadata to the mac mini but continue synching to the laptop, then immediately the databases start to diverge. Im not worried about play counts on the mac mini, but changes to my ratings on my ipod (my method of rating) will not flow through to the mac mini. I dont want to synch to the mini as my wife will totally wreck my play counts, as she plays the same music over and over again!! However, I would like updated ratings to be on both systems. Im not sure there is a solution to this, but any ideas would be welcomed!
    With pictures I want to maintain editing on my laptop as I have Elements 3.0 and dont fancy editing on my TV anyway. But of course I want to view my pictures through my mac mini on our tv!
    I am right in that maybe my best option would be to invest in a external network hard drive for my media to live on and have both computers access it that way? Im on a 54mbs wireless laptop, would an external hard drive be fast enough over that? plus its more expense I dont really want to spend!
    Apologies for the length, but I dont want to get this wrong and I know it will be harder to change if I start off on the wrong foot!
    Thanks
    Jared

    Just to hit one topic of your post...this utility might be a solution for you...
    http://www.findleydesigns.com/ipodaccess/index.html
    It painlessly merged my older MS Windows nano's songs with my current Mac iPod's library.

  • How to manage Active directory and tools to manage Active Directory

    How to manage Active directory and which tools we use?

    You can use Microsoft Active Directory management tools:
    http://technet.microsoft.com/en-us/library/aa998508(EXCHG.65).aspx
    http://technet.microsoft.com/en-us/library/aa998508(EXCHG.65).aspx
    erview of Server Message Block signing
    http://support.microsoft.com/kb/887429/en-us
    Remote Server Administration Tools for Windows 7:
    http://www.microsoft.com/downloads/details.aspx?FamilyID=7d2f6ad7-656b-4313-a005-4e344e43997d&displaylang=en
    AD Admin Center:
    http://technet.microsoft.com/en-us/library/dd560651(WS.10).aspx
    http://technet.microsoft.com/en-us/library/dd560652(WS.10).aspx
    Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX http://blogs.sivarajan.com/ http://publications.sivarajan.com/ This posting is provided "AS IS" with no warranties, and confers no rights.

  • Does anyone know how to manage the hotspot connections?

    Does anyone know how to manage the hotspot connections? Is there a way to see who is connected, disconnect a particular user, etc.? All I can see is the blue bar announcing the number of of connections.

    I should have phrased that better. I have multiple devices connected at the same time, sometimes I want to disconnect one only 1 of them. To do this I need to go to the device and disconnect or turn off the device. Is there a way I can disconnect selected devices on the phone? Not so much a matter of knowing who/what is connected, rather having control of these individual connections from the phone. Is this possible?

  • How to watch NFL network?

    I have the HTC 8X and recently saw that NFL games and NFL Network are included:
    http://www.verizonwireless.com/insiders-guide/inside/nfl/
    The season has not yet started so there aren't any games to watch but I wanted to check out NFL network to try it out.  I'm able to get into the NFL Mobile App without any problems but I don't see how you access NFL Network or NFL Games?  It looks like it's pointing me to add "NFL Game Pass" to do this but when I follow the link to game pass I get the following message:
    This app is not available for your device
    I'm in the US, on the 8X which has NOT yet been updated to 8.1
    Any ideas?
    Thanks,
    Ryan

    Hi,
    I have the Lumia 822 and my wife has the Icon and we haven't had any trouble beyond needing to remember to turn on the GPS. Did you manage to get it working?

Maybe you are looking for

  • Issue with process order confirmation

    Hi,   I m doing the testing of SAP EHP4 To EHP6 up-gradation. I tried to confirm process order XXXXXX with T-code COR6N. In this process order there 2 phase for 2 activity. Now when I entered the order in COR6N I click on enter its automatically take

  • Iphone and iTunes don't sync

    When i connect my iPhone my iTunes stops working (application not responding) someone please help. i already deleted all the podcast has i've been told in another forum, it still doesn't work.

  • Which IDoc type is related to material stock data?

    I didn't find any IDoc type existing which is related to stock overview (MMBE), just find message type LOISTD. Anyone can help please?

  • Conditionally Hide Regions based on :APP_USER

    Hey Guys, I have a pretty straight-forward question. I'm trying to hide a region unless the user = "ADMIN_JOHN" OR "ADMIN_TOM". Can someone please tell me: 1.) the condition type, 2.) what to write into expression 1 (and possibly expression 2). I've

  • Should We consider Temp Data Files While Estimating The Database Size

    Hi, The Database Size is sum of physical files like Control file redo log file datafiles temp files so i want to know why are we considering the temp files..Because it's temporary. At one stage of database, temp size it could me more and at one stage