473,396 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Set broadcast source ip-address

Hello community,

I'm currently writing a broadcast sender class in C# .NET (using .NET Framework 3.5).

On my computer there are more than one local network interface and if I send a broadcast, the UdpClient class choose "randomly" a source ip-address from a network interface.

Does anybody knows a possibility to set a specific sender ip-address?

Thank you in advance!

Greets from Switzerland,
Giovanni

Expand|Select|Wrap|Line Numbers
  1. IPAddress GroupAddress = IPAddress.Broadcast;
  2. int GroupPort = 11108;
  3. UdpClient sender = new UdpClient();
  4. IPEndPoint groupEP = new IPEndPoint(GroupAddress, GroupPort);
  5. byte[] bytes = Encoding.ASCII.GetBytes("Hello network.. (da08frup3)");
  6. sender.Send(bytes, bytes.Length, groupEP);
  7. sender.Close();
  8.  
inspiration by: http://social.msdn.microsoft.com/forums/en-US/netfxnetcom/thread/16b686d5-7c07-440f-9411-d311f3fb4a2f/
Sep 15 '08 #1
4 2312
Plater
7,872 Expert 4TB
I think with UdpClient, you can set your LocalEndPoint maybe?
Sep 15 '08 #2
I think with UdpClient, you can set your LocalEndPoint maybe?
That was my first idea, but the property is read-only :( (Note: the LocalEndPoint property is located in the class Socket).

I think the solution must be in the socket layer, but I couldn't see it :(
Sep 15 '08 #3
Plater
7,872 Expert 4TB
Did you see this constructor type:
UdpClient(IPEndPoint localEP)

So you could say:
UdpClient u = new UdpClient(myLocalEP)

See if that works?
Sep 15 '08 #4
Did you see this constructor type:
UdpClient(IPEndPoint localEP)

So you could say:
UdpClient u = new UdpClient(myLocalEP)

See if that works?
Dear Plater,

Thank you for your help, now it works!! I was so fixed to find the solution in the Socket class, that I not looked exactly in the UdpClient class..

Sorry for this newbie question..

Sincerelly yours,
Giovanni
Sep 17 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: pekspro | last post by:
I need some code that gets the address from a server. I read somewhere that you could do this by starting some broadcast server using UDP. The client should send an broadcast message, and when the...
4
by: André Nobre | last post by:
Hi all... I need to send a broadcast message thru my network (obvius...) with vb.net when some conditions get ok. Someone can indicate me material to study this subject? Or somes tips, I would...
3
by: LinuxGuy | last post by:
Hi All, I have 2 interfaces with IP addresses configured with same subnet on machine. my application need to send udp broadcast packet to subnet. but whenever I send any packet it is going...
7
by: sandy | last post by:
hello can anbody help me in getting source code for tcp/ip stack in ANSI C or source code for http protocol
7
by: GTi | last post by:
I need a code snippet for sending a message to all computers located on the same IP subnet. This is only a simple message like; "Here I am" I'm developing a server/client application. Instead of...
0
by: salman | last post by:
Hello i am working on real time application, there is many clients in network, some connected locally LAN and some via VPN through RAS (remote access service), I am facing problem to broadcast the...
0
by: salman | last post by:
Hello I have local network with ip(s) 192.168.1.x, and i am creating VPN through RAS- Remote Access Service (window server 2003) of ip range from 10.0.0.10 - 10.0.0.255. client are connecting to...
0
by: salman | last post by:
Hello i have to broadcast over vpn. I have local network and vpn, LAN ips are 192.168.1.x and vpn ips are 10.0.0.x. i am creating vpn thru windows server 2003 RAS. i have to broadcast msgs over...
7
by: sreehari | last post by:
Hi All, I have this problem, I have developed a Master - Slave kinda appliacation , were the slave is generally a device.when i broadcast a message from my application, the Device seems to...
3
Sagittarius
by: Sagittarius | last post by:
Hi there. I have a problem concerning an UDP socket in C++ (Winsock). The next paragraphs is merely to explain the system I am working on. If U want to skip it, I have marked the question in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.