What is the proper procedure for shutting down a TCPListener?

Should the Server (the socket) be shutdown before stopping the TcpListener?
sample:
if (theTcpListener != null)
  if (theTcpListener.Server != null)
    if (theTcpListener.Server.Connected)
      theTcpListener.Server.Shutdown(System.Net.Sockets.SocketShutdown.Both);
      theTcpListener.Server.Disconnect(false);
      theTcpListener.Server.Close();
    theTcpListener.Server.Dispose();
  theTcpListener.Stop();
  theTcpListener = null;

>>Should the Server (the socket) be shutdown before stopping the TcpListener?
Close any TcpClient ( TcpClient client = server.AcceptTcpClient(); ) and the call the Stop() method on the TcpListener object. Please refer to the following sample code for more information:
https://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
As the documentation states: the Stop method closes the underlying Socket and creates a new Socket for the TcpListener but you are responsible for closing your accepted connections separately:
https://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.stop(v=vs.110).aspx.
Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

Similar Messages

  • What is the proper procedure to backup to multiple external hard drives if one wishes to rotate drives such that you may store one in a fire safe?

    Description:  If I want to back up to two external hard drives using Time Machine, what is the proper procedure to follow such that I could keep one attached to Time Machine for daily backups, and one that I attach monthly such that I can back it up monthly, and then store it in a fire safe.  To do this, what are the exact steps to follow?
    Research in Progress:
    I selected the "?" icon in Time Machine which took me to "Mac Help - Time Machine Preferences" section.  I reviewed this section, including the "Select Backup Disk, Select Disk, Add or Remove Backup Disk."  It says, "If you haven’t set up Time Machine, click Select Backup Disk to set up a backup disk. Repeat the steps for each backup disk you want to set up."  I did add two backup disks.  It goes on to say "If you already set up Time Machine, your backup disks are listed, and information about each backup disk is shown. To select, add, or remove backup disks, click Select Disk or Add or Remove Backup Disk."  Well, what is lacking here is what happens when you "Remove" the backup disk.
    As I have read this section, it raises additional questions:
    What are some cautionary statements.
    What happens after you remove a backup disk?  Will Time Machine recognize it later?
    What is the proper procedure for removing and ejecting one of your external hard drive when you use it with Time Machine?  What happens if you don't "remove" a backup drive and instead just drag it to the "trash can, i.e. eject it" and later reconnect it.?

    Time Machine supports multiple backup drives including network area storage volumes (NAS) as well as physically-connected external backup drives.
    In , System Preferences, Time Machine, add the second drive by clicking Select Disk.
    All available connected drives including connected network drives are displayed.
    Select the additional drives, one at a time.
    Connected Network drives are displayed on the desktop only when actively being used by Time Machine for backup.
    When prompted, select 'use both' when adding the second drive.
    Then choose Select or Remove at the bottom of the list of available devices and network volumes to add additional drives.
    Time Machine then automatically rotates backups among the available designated devices and volumes.
    If the drive is physically not present, Time Machine skips to the next available backup drive.
    To DISMOUNT a drive to take it off-site, it is NOT necessary to remove it from the Time Machine preferences.
    When the drive is NOT in use, dismount it by Command+clicking that Drive icon on your desktop (or in Finder) and then "Eject".
    That's it.
    After 10 days with no backups to a given device, Time Machine does display a message and (as I recall) asks if you want to remove that drive from the rotation.
    You can never be too rich or have too many backups!

  • HT201401 What causes the iPhone 4S to shut down to a black screen when it has full power?

    What causes the iPhone 4S to shut down to a black screen when it has full power? I have cleared the open icons and it works for one day then shuts down again.

    Software hiccup, glitch or maybe faulty battery. Restore iPhone with iTunes on computer. See if this helps. If still problem that you think is serious enough to fix, all iPhone 4S have full Warranty. Make Genius Reservation and take iPhone to Apple for resolution.

  • What's the proper protocol for a reset on my ipod touch 4g?  iOS 6 has totally jacked it up and it will no longer do anything but crash, and won't sync with itunes wirelessly or by cable.

    What's the proper protocol for a reset on my ipod touch 4g?  iOS 6 has totally jacked it up and it will no longer do anything but crash, and won't sync with itunes wirelessly or by cable.
    It's a 64G ipod touch and was fine till Apple told me to upgrade to ios 6.  Now most of my apps crash, my music won't play and I just get a white screen when I hit Music.
    When I try to sync to itunes it acts like it's going to sync and appears to recognize the ipod, but it's grayed out and has an update circle by it that spins for a while until itunes eventually freezes alltogether.  Is there a  way to go back to ios 5 after a erase and reset?

    iOS: Unable to update or restore

  • What is the charging procedure for european travel do I need to use a transformer or just an adapter?

    what is the charging procedure for european travel? do  need to use a converter or just an adapter?

    The only thing would be an adapter, for example World Travel Adapter Kit from the Apple Store.
    The power supply will accept the 240V input in Europe.

  • Update my app. What is the correct procedure for updating an app/folio?

    I designed a folio in Indesign CS6 and created an app of the folio in adobe dps and succesfully uploaded it to the app store. Now I want to update my app. What is the correct procedure for updating an app/folio?

    no, just update your content and recreate the Single Edition App. Your certificate should still be valid so there is not need to recreate these.
    ... your App ID absolutely need to be the exact same one you used for the first version if you want to make sure this is an update.

  • What is the proper config for the Airport Extreme when a Voice over IP device is between the cable modem and the router.

    What is the proper config for the Airport Extreme when a Voice over IP device is between the cable modem and the router.  Its a VoIPo device. The cable modem is connected to the VoIP WAN port and the LAN port on the device feeds the Airport Extreme.  The VOIP is working fine, and my Mac are getting 10. addresses from the Airport Extreme.  But I do get confict messages and lose my connection periodicaly.  Looking for help.

    Its a VoIPo device.
    Per chance, is this device the Grandstream HT502?

  • Hi, I have a Iphone 5. Its a little physically damaged at corders of steel band and now its not getting boot up. I am from INDIA and what to know what is the excat procedure for my phone replacement. Phone is under warranty.

    hi can anone answer the question i have asked ??
    Ques: Hi, I have a Iphone 5. Its a little physically damaged at corders of steel band and now its not getting boot up. I am from INDIA and what to know what is the excat procedure for my phone replacement. Phone is under warranty.

    goelAkash wrote:
    now who is responsible ?? I think the apple care people are responsible as the phone was charging when they cleaned that charging jack. fault is at their end.
    It doesn't matter that the damage doesn't appear to be related to the problem you're having. Once the phone is damaged, the warranty is void.
    Forum etiquette note: you don't need to post the identical response three times.
    Best of luck.

  • I use photo stills in my iMovie. I want them to last longer than a minute, but when I input 01: 45: 00, to signify one min. and 45 seconds, it doesn't accept it. What is the proper format for inputting minutes?

    I use photo stills in my iMovie. I want them to last longer than a minute, but when I input 1:45:00, to signify one minute and 45 seconds, it doesn't accept it. What's the proper way to input it?

    There are 30 frames in one second of video. So you can specify down to the frame level, which is 1/30th of a second.
    Is the Duration box switching to some other time every time you type in 1:45:00?
    For instance this is a 5 second clip plus 3 frames. To get this set properly I would type in 1:45:00, then click done. I don't know if it is different under older versions of iMovie, as I'm using iMovie '11 for thisi example.

  • What is the correct procedure for upgrading to aperture 3.4

    I am working in South Sudan and am shortly going to be in a place where I can download all the updates. The last time I did an update was around 2 weeks ago.
    I presume that there will be updates for Mountain Lion, iPhoto and Aperture, plus a whole pile of iOS updates. From the support questions I see that there is a number of people having problems.
    I presume that the first thing to do will be to rebuild the library of aperture.
    What is the correct procedure after that?

    If I do an upgrade through AppStore, and find it does not work, do I uninstall first by removing to trash? What do you mean by revert to an earlier version, and which previous version of Aperture should I use.
    Neville,
    So you did buy Aperture from the AppStore?
    Then move the Aperture application to the Trash, but do not empty it, just in case
    Sign into the AppStore and reinstall. In this case you do not need to revert to an earlier version. If the AppStore installer does not find an Aperture in your Applications folder, it will have to make a full install, and no incompatible frameworks should remain, as is the problem with the partial upgrades right now.
    Yes, I have a bootable clone,
    And have you checked, if you really can boot from your clone? Just being very cautious.
    Do you use facebook? Some posters are having problems, even after reinstalling, if the want to publish to Facebook. Post back, if you encounter that problem.
    Good Luck
    Léonie

  • VT01N: what is the correct  procedure for creating shipment

    Hi Gurus ,
    Please tellme the correct  procedure for creating shipment  in VT01N   with respect to the  Sales order  no .  there  are  deliveries and ohter  sceens what to do  first .
    Regards, Jaspal

    Hi Jaspal,
    Procedure for creating shipment sequence goes as:
    <b>Shipping Processing and Analyses</b>
    Shipping activities.
    Deliveries.
    Picking and confirmation.
    Packing.
    Goods issue.
    Collective processing.
    Shipment.
    Billing.
    Sales Information System.
    Standard analyses.
    Backorder processing.
    Sales and distribution documents.
    Functional analyses.
    Planning.
    Pls refer the link:
    http://www.sap-img.com/sap-sd.htm for more details.
    Regards,
    Hemachandra K S

  • What is the proper name for Mac OS? OS X? Apple Mac OS X?

    It's a tad bit confusing for me since I am new to Apple.
    What do you call it the true name for it?
    Apple Mac OS?
    OS X?
    If I type in OS X It shows all the versions released form Apple.
    Like in the snap shot below.
    http://i1157.photobucket.com/albums/p600/napninjanx/Snapshots/Untitled_zps2d1aa9 90.png
    When I searched for MAC OS it did not show the versions of released OS X for Apple.
    Like in the snapshow below.
    http://i1157.photobucket.com/albums/p600/napninjanx/Snapshots/2_zpsbae85e49.png
    But when I searched on eBay for Snow Leopard it showed the brand name
    http://i1157.photobucket.com/albums/p600/napninjanx/Snapshots/3_zpsbcb588ac.png
    Then I thought going by brand name and model is the way to know the proper name for it.
    I think the proper name for it is Apple Mac OS X that's how you type it in order to know other realses if I am not mistaken.

    You can call it Mac OS X or OS X and others will know what you mean.
    If you click the apple at the left side of the menu bar, About This Mac, you will see OS X so that is what Apple calls it.

  • What is the T code for paying down payment for assets

    hi,
    please let me know if , f-90 has to be used for downpayment with transaction type 180, or there is any other transaction for it

    Hello Sai
    Define the asset number and sub-number as optional entry in accounts payable Customizing in the field status group for the reconciliation account for vendor down payments (transaction OBC4).
    In the field status of the posting key for vendor down payments, you also need to define the asset number and sub-number as optional entry.
    Then you can enter the asset under construction when posting with F-48 and accounts for asset down payments will be posted.
    Regards
    Javier Reviriego

  • Ownership/Group/Permissions What is the proper setting for free access?

    When we first get a customer supplied disk, it is copied to our G5. It looks like whomever is logged into the G5 and copies the disk becomes the owner of that folder and their permissions are applied to the enclosed copied files.
    We never know who will wind up working on these files and I want anyone to have free and open access to the files.
    So what it the proper choice under the ownership & permissions?
    My thinking would be:
    Owner = System
    Group = Everyone
    Access = Read & Write
    There are bunch of acromyms under these pulldown menus which mean nothing to me.

    Choosing 'everyone' and 'read & write' should work fine.
    You could change the owner to 'system', but there's no need.

  • What is the PROPER plugin for Windows Media Player 12 - Prompt leads to WMP 11

    Is the plugin for WMP 11 the proper plugin for the WMP 12 64 bit system?
    Is this WMP 11 plugin the version of the plugin itself or for WMP Version 11?
    One web cam I tried to view said it needed this plugin, it wouldn't download; said to do it manually. When I tried it listed the Windows systems w/bit system information and Windows XP SP2 (x86)
    Windows XP SP2 (x64)
    Windows Vista (x86)
    Windows Vista (x64)
    There is nothing offered for Windows 7 at all, much less for this 64 bit system as it does for the two above systems. This is very unclear, and with so many problems posted all over the Internet.... and having lost graphic card ability and later memory burn out on last computer due to this same issue in Vista, I would really appreciate the proper plugin information relating to this issue so I can safely use my computer.
    Who creates the plugins?T Firefox or Microsoft? How can this problem go on for so many years unresolved? Thanks for your insight.

    You need a 32 bit Windows Media Player and a 32 bit plugin for it.<br />
    I don't think that the WMP plugin will work with a 64 bit WMP version.<br />
    Firefox is 32 bit as well.
    The WMP plugin that you found works with WMP 12.
    * http://www.interoperabilitybridges.com/windows-media-player-firefox-plugin-download

Maybe you are looking for