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. I hate server/client code....

I hate server/client code....

Scheduled Pinned Locked Moved C#
helpsysadminquestionworkspace
2 Posts 2 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.
  • M Offline
    M Offline
    methodincharge
    wrote on last edited by
    #1

    Seriously, I have been fooling around with this code for a week or so and I always end up back to sqaure 1. Can anyone see any flaws in the theoretical setup below? * I am using sockets (CLIENT/SERVER) * I use Async code for the BeginAccept and EndAccept on the socket (SERVER) * I use Async reading for the messages coming in (CLIENT/SERVER) * Using a single thread to send messages on the socket which utilizes an ArrayList of messages, clones the arraylist, does a foreach then writes each message then removes the message from the original arraylist[not the cloned] (CLIENT/SERVER) A big problem I am having is that messages will come in like: MESSAGE:blah:connect MESSAGE:blah:messageMESSAGE:blah:somethingMESSAGE:blah:networks blow And obviously I am expecting the messages to come in one at a time. I assumed that if I wrote them synchronously then the async receiving should work the way I intend. Is there a problem with this? Any help or guidance would certainly be appreciated.

    J 1 Reply Last reply
    0
    • M methodincharge

      Seriously, I have been fooling around with this code for a week or so and I always end up back to sqaure 1. Can anyone see any flaws in the theoretical setup below? * I am using sockets (CLIENT/SERVER) * I use Async code for the BeginAccept and EndAccept on the socket (SERVER) * I use Async reading for the messages coming in (CLIENT/SERVER) * Using a single thread to send messages on the socket which utilizes an ArrayList of messages, clones the arraylist, does a foreach then writes each message then removes the message from the original arraylist[not the cloned] (CLIENT/SERVER) A big problem I am having is that messages will come in like: MESSAGE:blah:connect MESSAGE:blah:messageMESSAGE:blah:somethingMESSAGE:blah:networks blow And obviously I am expecting the messages to come in one at a time. I assumed that if I wrote them synchronously then the async receiving should work the way I intend. Is there a problem with this? Any help or guidance would certainly be appreciated.

      J Offline
      J Offline
      John Fisher
      wrote on last edited by
      #2

      I believe that you are running into a feature of the system. When your software takes longer to read the communications from the socket, the messages will pile up. At the next read, you can then retrieve (with one call) all the messages which have been sent. So, your network protocol needs some method of delineating between the end of one message and the beginning of another. Once you have that arranged, you ought to be free of this problem. John
      "You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.

      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