I have already tried this URL's code
but I am getting error when i am creating a UDP type Socket and recieving
packet from this socket.
some time error is---"An existing connection was forcibly closed by the
and some time error is---
"A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond"
i am using this code for
IPHostEntry ihe = Dns.GetHostEntry(host);
IPEndPoint iep = new IPEndPoint(ihe.AddressList, 161);
EndPoint ep = (EndPoint)iep;
Socket sock = new Socket(ep.AddressFamily, SocketType.Dgram,
sock.SendTo(packet, snmplen, SocketFlags.None, iep);
//Receive response from packet
packet = new byte;
int recv = sock.ReceiveFrom(packet, ref ep);
//here I am getting above written exceptions
catch (SocketException ex)
packet = 0xff;
pls help me out of this its very urgent.