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. Network programming

Network programming

Scheduled Pinned Locked Moved C#
csharpsysadmin
4 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.
  • F Offline
    F Offline
    felopater
    wrote on last edited by
    #1

    hiiii, i send datagrams through internet using udpclient class defined in .net namespace, but it never reach it's destenation. i know that udp is unreliable protocol. but not even one packet arrives!!!!!!!!!!! marcoryos

    H 1 Reply Last reply
    0
    • F felopater

      hiiii, i send datagrams through internet using udpclient class defined in .net namespace, but it never reach it's destenation. i know that udp is unreliable protocol. but not even one packet arrives!!!!!!!!!!! marcoryos

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

      felopater, Without any code snippets it's nearly impossible to say why. Please post examples of your code so that we may help you. Please also take a look at example and documentation for the UdpClient class online in the .NET Framework SDK at http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemNetSocketsUdpClientClassTopic.asp[^]. 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]

      F 1 Reply Last reply
      0
      • H Heath Stewart

        felopater, Without any code snippets it's nearly impossible to say why. Please post examples of your code so that we may help you. Please also take a look at example and documentation for the UdpClient class online in the .NET Framework SDK at http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemNetSocketsUdpClientClassTopic.asp[^]. 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]

        F Offline
        F Offline
        felopater
        wrote on last edited by
        #3

        /********************************/ UDPClient Client=new UdpClient(); Client.Bind(new IPEndPoint(Dns.GetHostByName(Dns.GetHostName()).AddressList[0],5000); byte[]result; MemoryStream stream=new MemoryStream(); foreach(UserInfo info in GroupUsers) { if(compare(info,MyClientInfo)) continue; seachMessage.Destenation=info; SerialSearch.Serialize(stream,seachMessage); Client.Send(stream.GetBuffer(),(int)stream.Length,new IPEndPoint(info.IP,info.port)); stream=new MemoryStream(); } IPEndPoint point=new IPEndPoint(IPAddress.Any,0); while(true) { try { result=Client.Receive(ref point); q.Enqueue(result); } catch(SocketException ex) { break; } /************************************/ that's was part of my code. it works fine on lAN, by the way UDPClient i Inherited from UdpClient just to use client protected member to set socket timeout so it won't block forever,and i set it in Constructor. am afraid that the problem from UDP datagram size. becouse SearchMessage object after serialization about 2k thanx so much for your time. marcoryos

        H 1 Reply Last reply
        0
        • F felopater

          /********************************/ UDPClient Client=new UdpClient(); Client.Bind(new IPEndPoint(Dns.GetHostByName(Dns.GetHostName()).AddressList[0],5000); byte[]result; MemoryStream stream=new MemoryStream(); foreach(UserInfo info in GroupUsers) { if(compare(info,MyClientInfo)) continue; seachMessage.Destenation=info; SerialSearch.Serialize(stream,seachMessage); Client.Send(stream.GetBuffer(),(int)stream.Length,new IPEndPoint(info.IP,info.port)); stream=new MemoryStream(); } IPEndPoint point=new IPEndPoint(IPAddress.Any,0); while(true) { try { result=Client.Receive(ref point); q.Enqueue(result); } catch(SocketException ex) { break; } /************************************/ that's was part of my code. it works fine on lAN, by the way UDPClient i Inherited from UdpClient just to use client protected member to set socket timeout so it won't block forever,and i set it in Constructor. am afraid that the problem from UDP datagram size. becouse SearchMessage object after serialization about 2k thanx so much for your time. marcoryos

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

          You're not instantiating a UDPClient, however, but a UpdClient. You're declared type isn't so much important as what you instantiate. If you want your overridden protected member - of even your constructor - to be called you must instantiate your class:

          UDPClient client = new UDPClient();
           
          // OR
           
          UdpClient client = new UDPClient();

          The inheritance model means that your overridden method or constructor will be called instead of your declaring type (UdpClient). That may solve your problem if I understand your problem correctly. 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