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. Udp. How to recieve.

Udp. How to recieve.

Scheduled Pinned Locked Moved C#
helpsysadmintutoriallounge
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.
  • U Offline
    U Offline
    Umair Ahmad khan
    wrote on last edited by
    #1

    I have just started this. and i m trying to make a chat application that runs over LAN. there might be many other ways and they might be better then using Udp port but i want to understand this thing. i have read some articles before posting but i m now having problem on receiveing messages. public void waitData() { while(true) { IPEndPoint from = new IPEndPoint(IPAddress.Any,170); string result = ""; Byte[] drec = receive.Receive(ref from); result = Encoding.ASCII.GetString(drec); textBox1.Text = result.ToString(); } } this code is to recieve messages and i made a thread so it keep waiting for any message to recieve. and i m broadcasting message to network. i m new to this so plz help me :sigh: i think its enough to explain what i want to do but if still you think i had to tell more. tell me.

    H 1 Reply Last reply
    0
    • U Umair Ahmad khan

      I have just started this. and i m trying to make a chat application that runs over LAN. there might be many other ways and they might be better then using Udp port but i want to understand this thing. i have read some articles before posting but i m now having problem on receiveing messages. public void waitData() { while(true) { IPEndPoint from = new IPEndPoint(IPAddress.Any,170); string result = ""; Byte[] drec = receive.Receive(ref from); result = Encoding.ASCII.GetString(drec); textBox1.Text = result.ToString(); } } this code is to recieve messages and i made a thread so it keep waiting for any message to recieve. and i m broadcasting message to network. i m new to this so plz help me :sigh: i think its enough to explain what i want to do but if still you think i had to tell more. tell me.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      So what's the problem? Also, don't keep reinstantiating your IPEndPoint in your while loop. You only need to do this once per end point required for your application. If you're having trouble using UDP classes in .NET then be sure to read about them in the .NET Framework SDK, like the UdpClient[^] class. Many of these include examples and reading about what the methods and properties actually do is important. The documentation I've linked in particular shows you how to send and receive buffers using the UdpClient. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

      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