lextudio / sharpsnmplib

Sharp SNMP Library- Open Source SNMP for .NET
https://sharpsnmp.com
MIT License
356 stars 152 forks source link

Defined UDP client source port #359

Open lextudio-support opened 2 hours ago

lextudio-support commented 2 hours ago

Hello all,

first of all, i would like to thank all the contributors who made this great library work.
I would like to use it to monitor and control some devices spread in the network.

Unfortunately the managed devices are somewhat picky about where the SNMP requests come from
regarding the data's source port. When looking at the source code, i find that each time SNMP/UDP will be sent,
a new UdpClient is created using the UdpClient's default constructor, without defining a certain source port.

In general, this would be possible:
Example on MSDN
UdpClient Construtor on MSDN

I think it would be great, if the source port for the UDP socket opened could be set/defined e.g. using the Manager.
Would this be useful to others? And would it be possible? For me, this is a missing feature.

Looking forward to comments,
Marco Stein,
Systems Engineer
Munich, Germany

Original Reported Date: 2009-03-24T14:16:21.487-07:00 Original CodePlex Discussion Thread ID: 51186

lextudio-support commented 2 hours ago

Copied from CodePlex without authors:

Hi again,

i have just donwloaded "sharplib 18885" and seen that the usage of UdpClient is gone.
Instead now, Socket is used.
So the socket could be bound to a defined source port address before sending.

IPAddress

localip = IPAddress.Parse("192.168.10.250");

IPEndPoint lipe = new IPEndPoint(localip, 64000);

udpSocket.Bind(lipe);

looking forward to comments,
Marco

Original Posted Date: 2009-03-25T00:56:01.06-07:00