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. C# window app to listen multiple port simultaneously..

C# window app to listen multiple port simultaneously..

Scheduled Pinned Locked Moved C#
csharptutorial
8 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.
  • A Offline
    A Offline
    ayandelhi
    wrote on last edited by
    #1

    Hi!! Hello every one... I wanted to know what should i do to keep on listening to multiple ports for msgs and displaying on respective text boxes. i've tried asych sockets. but cant get it right.. it listens for only one time. if i start a while loop the whole app stops responding.. i hope threading is a answer but i know nothing abt it.. plz guide me..

    L 1 Reply Last reply
    0
    • A ayandelhi

      Hi!! Hello every one... I wanted to know what should i do to keep on listening to multiple ports for msgs and displaying on respective text boxes. i've tried asych sockets. but cant get it right.. it listens for only one time. if i start a while loop the whole app stops responding.. i hope threading is a answer but i know nothing abt it.. plz guide me..

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

      Hi, 1. the question is unclear. What ports? TCP/IP ports? SerialPort instances? ... 2. regardless, you can handle that with either asynchronous methods and events, or by having some kind of thread and a blocking read. 3. in any case, you can't touch GUI Controls from threads other than the main thread. So don't try myTextBox.Text="got something"; inside a DataReceived handler. The solution is here[^]. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      A 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, 1. the question is unclear. What ports? TCP/IP ports? SerialPort instances? ... 2. regardless, you can handle that with either asynchronous methods and events, or by having some kind of thread and a blocking read. 3. in any case, you can't touch GUI Controls from threads other than the main thread. So don't try myTextBox.Text="got something"; inside a DataReceived handler. The solution is here[^]. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

        A Offline
        A Offline
        ayandelhi
        wrote on last edited by
        #3

        Ans 1. TCP/IP Ports... Ans 2. How can i use Threading in GUI app??? i've textbox1 and textbox2. now i need to listen port port1 and port2 and direct the received msgs to their respective textboxes. Ans 3. thanks for that.. i've studied it already.. that cross thread funcs..

        L 1 Reply Last reply
        0
        • A ayandelhi

          Ans 1. TCP/IP Ports... Ans 2. How can i use Threading in GUI app??? i've textbox1 and textbox2. now i need to listen port port1 and port2 and direct the received msgs to their respective textboxes. Ans 3. thanks for that.. i've studied it already.. that cross thread funcs..

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

          ayandelhi wrote:

          How can i use Threading in GUI app???

          threading is the same in all kinds of apps, whether GUI, Console, or headless. However to access Controls you need to Invoke. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at them.

          A 1 Reply Last reply
          0
          • L Luc Pattyn

            ayandelhi wrote:

            How can i use Threading in GUI app???

            threading is the same in all kinds of apps, whether GUI, Console, or headless. However to access Controls you need to Invoke. :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at them.

            A Offline
            A Offline
            ayandelhi
            wrote on last edited by
            #5

            I'm lost in it.. i cant see thru it.. when i type a msg in msg text box i shud start a thread which sends it to client n then waits until a msg is received from client. Right.. or something else.. One more thing... how much time does it take a msg to get delivered from client to server on a lan of max 10 pcs.. i'm asking this coz i want active feed from my clients.. wheneva they type anything on their app it shud be displayed on my window...

            L 1 Reply Last reply
            0
            • A ayandelhi

              I'm lost in it.. i cant see thru it.. when i type a msg in msg text box i shud start a thread which sends it to client n then waits until a msg is received from client. Right.. or something else.. One more thing... how much time does it take a msg to get delivered from client to server on a lan of max 10 pcs.. i'm asking this coz i want active feed from my clients.. wheneva they type anything on their app it shud be displayed on my window...

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

              ayandelhi wrote:

              I'm lost in it.. i cant see thru it.. when i type a msg in msg text box i shud start a thread which sends it to client n then waits until a msg is received from client. Right.. or something else..

              I don't see a specific question here. if you are not familiar with the subject, read up on it, think about it, and experiment. when stuck, ask a specific question.

              ayandelhi wrote:

              how much time does it take

              42 msec. how long is your message? how fast is your LAN? what other traffic is there? how inefficient is your code? if you now some app that does things similar to what you want, then that proves it can be done; if not, it may be an indication it can't be done. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at them.

              A D 2 Replies Last reply
              0
              • L Luc Pattyn

                ayandelhi wrote:

                I'm lost in it.. i cant see thru it.. when i type a msg in msg text box i shud start a thread which sends it to client n then waits until a msg is received from client. Right.. or something else..

                I don't see a specific question here. if you are not familiar with the subject, read up on it, think about it, and experiment. when stuck, ask a specific question.

                ayandelhi wrote:

                how much time does it take

                42 msec. how long is your message? how fast is your LAN? what other traffic is there? how inefficient is your code? if you now some app that does things similar to what you want, then that proves it can be done; if not, it may be an indication it can't be done. :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at them.

                A Offline
                A Offline
                ayandelhi
                wrote on last edited by
                #7

                actually... m running both client n server on my pc.. n m typin on client and it shud be visible as it is.. m sending the text to a file too and to server too.. on file i've complete text but m not getting on the server side.. i want a live feed of wat is the user typing on client not the file.. help me out..

                1 Reply Last reply
                0
                • L Luc Pattyn

                  ayandelhi wrote:

                  I'm lost in it.. i cant see thru it.. when i type a msg in msg text box i shud start a thread which sends it to client n then waits until a msg is received from client. Right.. or something else..

                  I don't see a specific question here. if you are not familiar with the subject, read up on it, think about it, and experiment. when stuck, ask a specific question.

                  ayandelhi wrote:

                  how much time does it take

                  42 msec. how long is your message? how fast is your LAN? what other traffic is there? how inefficient is your code? if you now some app that does things similar to what you want, then that proves it can be done; if not, it may be an indication it can't be done. :)

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at them.

                  D Offline
                  D Offline
                  DaveyM69
                  wrote on last edited by
                  #8

                  Luc Pattyn wrote:

                  42 msec

                  :thumbsup:

                  Dave
                  Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
                  BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

                  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