Network programming
-
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
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] -
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]/********************************/ 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
-
/********************************/ 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
You're not instantiating a
UDPClient
, however, but aUpdClient
. 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]