473,703 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UDP Broadcast recieve

I can't figure out why my code does not recieve the message. The only
message that it receives is the one going out from my machine. I am
suppose to send out a message to a server. Upon receiving that message
on the server side the server is suppose to send a message back. I
can't get my app to receive that message. It only receives the one
being sent out by my machine. I know that the server is sending out a
message because there is another app in vb that receives the message.
Here is my code:

private constructor()
iepSend = new IPEndPoint(IPAd dress.Broadcast , UDP_PORT);
epSend = (EndPoint)iepSe nd;

iepRx = new IPEndPoint(IPAd dress.Any, UDP_PORT);
epRx = (EndPoint)iepRx ;

m_SocketUDP = new Socket(AddressF amily.InterNetw ork, SocketType.Dgra m,
ProtocolType.Ud p);
m_SocketUDP.Set SocketOption(So cketOptionLevel .Socket,
SocketOptionNam e.Broadcast, 1);
m_SocketUDP.Set SocketOption(So cketOptionLevel .Socket,
SocketOptionNam e.ReuseAddress, 1);
m_SocketUDP.Con nect(epSend);

udpRxSocket = new Socket(iepRx.Ad dressFamily, SocketType.Dgra m,
ProtocolType.Ud p);
udpRxSocket.Set SocketOption(So cketOptionLevel .Socket,
SocketOptionNam e.ReuseAddress, 1);
udpRxSocket.Set SocketOption(So cketOptionLevel .Socket,
SocketOptionNam e.ReceiveTimeou t, 5000);
udpRxSocket.Bin d(iepRx);

SetupReceiveCal lbackUDP()

private void SetupReceiveCal lbackUDP()
AsyncCallback receiveData = new AsyncCallback(O nReceiveData);
udpRxSocket.Beg inReceiveFrom(b uffer, 0, buffer.Length,
SocketFlags.Non e, ref epRx, receiveData, udpRxSocket);

private void OnReceiveData(I AsyncResult ar)
Socket socket = (Socket)ar.Asyn cState;

int nBytesRec = socket.EndRecei veFrom(ar, ref epRx);
if(nBytesRec > 0)
string Received = Encoding.ASCII. GetString(buffe r, 0, nBytesRec);
//Received += socket.RemoteEn dPoint.ToString ();
WriteOutput("Re ceived Data: " + Received);
SetupReceiveCal lbackUDP();
catch(Exception e)
WriteOutput("Er ror. "+ e.Message);

Anyone know whats wrong?

Dec 19 '05 #1
1 2007
I can't figure out why my code does not recieve the message.

Unfortunately I don't have the time to review your code, but two things come
into mind architecture-wise: firewall settings and network errors.

Years ago I wrote a simple system to broadcast UDP messages to a local
subnet. This solution worked well when the 10 MB Ethernet network wasn't
busy, but when there were lots of traffic, those little UDP messages simply
were "missing in action". The same thing might happen to you.

Also, if it only happens that the server sees your client's messages but not
the other way around, check the (desktop)firewa ll settings on the server
(for outbound UDP blocking) and on your client (for incoming blocks).

Hope this helps.


Mr. Jani Järvinen
Helsinki, Finland
ja***@removethi s.dystopia.fi
Dec 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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 server answering the client gets the address. But how do I implement this? I did this simple quick-hack: Server: Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
by: K.K. | last post by:
I am writing program that will recieve or sent data to selected port (users can select which port they want to recieve or sent) but I don't know how or whick object I can use.
by: Jody L. Whitlock | last post by:
I'm kinda stumped at the moment, so... Here's what I'm looking to do: I have a ClientSocket, and I would like to free-thread the recieve end of it. I tried a delegate, but that won't fire. I'm thinking of using a networkstream, but can't really find anything on that. The purpose behind this is becuase my current solution is dropping bytes. I will post my class here....
by: Dave | last post by:
I can't figure out why my code does not recieve the message. The only message that it receives is the one going out from my machine. I am suppose to send out a message to a server. Upon receiving that message on the server side the server is suppose to send a message back. I can't get my app to receive that message. It only receives the one being sent out by my machine. I know that the server is sending out a message because there is...
by: Dave | last post by:
Does anyone have an example of how to receive a connectionless(udp) broadcast in c#. I have tried everything i can possibly think of and it won't recieve the message. I know that the message is coming in and that its not being blocked because there is another app on my machine that is getting the message. Please help.
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 recieve the message and responds correctly, and replies with a broadcast frame. Here is where i face the problem, what happens is that my application seems to Time out even if Ethereal ( Network Sniffer ) detects and shows all the frames that were
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 bold below it. I have a pc, connected to a network of boards, all connected in a ring, all having their own unique IP adresses. As it is now, I send messages to the network of boards via broadcast, so all the boards gets the message. All the...
by: ericlangland | last post by:
Hi, I have a small managed code application (windows forms) that executes on startup and immidiatly minimizes to the system tray. It launches and shows the form when I double click it's small icon in the system tray. So far so good. I'd like for the app to maximize outside of the system tray when the Windows + ? combination keys are selected. It seems that I can catch keystrokes when the form is showing but when minimized(Hide()) it in...
by: 4project | last post by:
i wanted to design a user interface such that i can handle all the incoming and outgoing calls , also send and recieve sms. I know that for sure that we can 1a .call 2a send sms but not sure if we can 1b. recieve a call 2b., receieve an sms.
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.