[Mono-list] Has Anyone Read UDP Data with Mono?

Steve Ricketts velocedge at hotmail.com
Sun May 9 13:35:59 EDT 2010


Robert, thanks so much for trying to help me out.  I'm feeling like an idiot
here.  I tried your sample and it's still not reading the data... just
hanging on the sock.ReceiveFrom statement.  I am including my entire
program.  I hard coded the IP/Port and tried 192.168.1.66 too.  I also
changed Receive to return byte[] since that's what I'm sending to it (from
an existing Windows application).  I've also included a packet from the
sniffer output so you can see that there really is data coming to port 6267.  

using System;
using System.Net;
using System.Net.Sockets; 

namespace testsocket
{
	class MainClass
	{
		class Receiver
		{
	        System.Net.Sockets.Socket sock;
	       
	        public Receiver(IPEndPoint endPoint)
	        {
	                sock = new
System.Net.Sockets.Socket(AddressFamily.InterNetwork,SocketType.Dgram,
ProtocolType.Udp);
	                sock.Bind (endPoint);
	        }
	
	        public byte[] Receive()
	        {
	                EndPoint clientEndPoint = new IPEndPoint(IPAddress.Any, 0);
	                byte[] data = new byte[1024];
	                int count = sock.ReceiveFrom(data, ref clientEndPoint);
	                return data;
	        }
		} 		
		public static void Main (string[] args)
		{
	        IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse
("127.0.0.1"), 6267);
            var r = new Receiver (localEndPoint);
			byte[] bt = r.Receive();

		}
	}
}


238 Byte, Timestamp (1273425821.525815 s) 
 [ MAC (08:00:45:00:00:e0 => 40:61:86:4f:6b:06), Proto (0x0800) ] 
 [ Addr (192.168.1.67 => 192.168.1.66), Proto (17), TTL (128), TOS (0), Ver
(1024), IHL (1280), Tlen (224), ID (25238), Frag off (0), Chsum (0x53a1) ] 
 [ Port (6279 => 6267), Len (204), Chsum (0x85b7) ] 
 [ Payload hex  (9a 09 5d 59 c4 4b c1 9a c9 53 52 22 cc 61 4b 
   39 61 d4 24 6f 81 cb 86 78 ad 1a 4e 21 6d bd b6 25 8d 91 
   8d dd 49 f1 10 c2 b1 27 b9 d1 f3 0c 3e 14 09 65 45 b2 12 
   98 6d 43 4b b5 c8 16 3a 31 fc dd c8 57 08 d7 dd 06 ec 61 
   73 49 92 21 2b 6c 81 1e 9f a4 83 34 8d c0 9a c4 64 42 c6 
   8d 40 7d cc 8d e3 6e 8d f1 e1 49 f0 14 56 fd ee 68 d0 ca 
   1d da ad 99 ca 60 d0 12 26 31 13 b6 8c c4 16 38 8c fc 9a 
   b9 d6 f8 5a d9 a6 06 81 f5 ba f1 b7 da 2d 61 ad da 6d 75 
   f4 2d 61 43 93 70 9c c6 4e 01 d4 ba 72 8b 69 95 af 59 4d 
   c9 26 4c 9e 24 d5 75 b6 1c fa 6e 8b 36 8e b6 12 44 49 cb 
   56 95 e3 0e 14 ed 52 8b ae 01 ) ] 

-- 
View this message in context: http://mono.1490590.n4.nabble.com/Has-Anyone-Read-UDP-Data-with-Mono-tp2135475p2164561.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list