Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. TCPIP server single connection

TCPIP server single connection

Scheduled Pinned Locked Moved C#
csharpsysadminquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ikurtz
    wrote on last edited by
    #1

    hi im coding c# sockets in Asynchronous mode. my app is running but i need to limit the number clients to one. so if a connection already exists i want the server to refuse any new connection. but using async methods i cant stop it from listening. the server will have to be restarted everytime the unique connection is terminated, so i dont need it to serve next new connection. how could i refuse new connections when async does not support it? thank you very much.

    J 1 Reply Last reply
    0
    • I ikurtz

      hi im coding c# sockets in Asynchronous mode. my app is running but i need to limit the number clients to one. so if a connection already exists i want the server to refuse any new connection. but using async methods i cant stop it from listening. the server will have to be restarted everytime the unique connection is terminated, so i dont need it to serve next new connection. how could i refuse new connections when async does not support it? thank you very much.

      J Offline
      J Offline
      Jimmanuel
      wrote on last edited by
      #2

      Whether you're using synchronous or asynchronous methods you have to explicitly tell the TcpListener or Socket to accept a new connection using one of the BeginAccept or Accept methods. If you don't want more than one client connected then don't call those methods more than once.

      :badger:

      I 1 Reply Last reply
      0
      • J Jimmanuel

        Whether you're using synchronous or asynchronous methods you have to explicitly tell the TcpListener or Socket to accept a new connection using one of the BeginAccept or Accept methods. If you don't want more than one client connected then don't call those methods more than once.

        :badger:

        I Offline
        I Offline
        ikurtz
        wrote on last edited by
        #3

        perfect! i understand it now. thanks.

        L 1 Reply Last reply
        0
        • I ikurtz

          perfect! i understand it now. thanks.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          are you sure you still want asynchronous operation if all that is going on is a single connection? seems to me you're paying the bills but not getting the goods. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          Happy New Year to all.
          We hope 2010 soon brings us automatic PRE tags!
          Until then, please insert them manually.


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups