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;
try
{
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? 0 1120 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Damir Hakimov |
last post by:
Hi All!
I'm writing a small programm which must send and service UDP broadcast
packets.
As start of it I looked at
/usr/share/doc/python2.4/Examples/Demo/sockets/broadcast.py
damir@debian-IBM:/usr/share/doc/python2.4/examples/Demo/sockets$
python2.4 broadcast.py
Traceback (most recent call last):
|
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: Frank Esser |
last post by:
Hello!
I have got machines that answer a certain UDP broadcast request with certain
information about them.
Some years ago I wrote a VB6 application that just sent out this UDP
broadcast request and received all machine information to display all
available machines in a grid.
Now I want to write the same application in C# but so far with no success.
|
by: gregory_may |
last post by:
First the research links:
IPv6 spec (look for 'jumbo payload'):
http://www.cs-ipv6.lancs.ac.uk/ipv6/documents/rfcs/archive/rfc1883.txt
IPv6 Sample C# Client/Server
http://www.codeproject.com/csharp/ipv6.asp
I am developing an application where I need to broadcast information to
clients. I have hit a 64K limit in UDP broadcasting. I am not exited
|
by: Shawn G. |
last post by:
I'm going around in circles here and need some help.
Scenario: I am using (have used) either the UDPClient class or Sockets
class to broadcast some bytes to 255.255.255.255 (udp protocol). Upon doing
so, a device (of which I will know nothing about) will receive my broadcast
and send out a broadcast of its own. Using Ethereal (LAN packet sniffer), I
can see my broadcast, and I can see the device broadcast. I cannot however
receive...
| |
by: Gunnar_Frenzel |
last post by:
Hello,
this might be an easy question, but I don't have any handy solution at
hand. I have an application that is supposed to send UDP broadcast. So
far so easy, I did:
Socket sockSendBroadcast = null;
IPEndPoint ipeSendBroadcast = null;
ipeSendBroadcast = new IPEndPoint(IPAddress.Broadcast, iSomePort);
|
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: Irmen de Jong |
last post by:
Hello
Sorry this might be a bit offtopic but I don't really know where else
to post this question. If you could point me in the right direction that
is much appreciated.
I'm running into a weird thing on Windows XP.
I'm using Python 2.5 with latest pywin32 from Mark Hammond.
|
by: Mali Findik |
last post by:
Hi @ll,
i've got problems with sending an UDP broadcast datagramm over two
network interfaces.
The code is like this:
<Code>
UdpClient client = new UdpClient();
IPEndPoint remoteEndPoint =
new IPEndPoint(IPAddress.Parse("255.255.255.255"), 1234);
|
by: raviskar |
last post by:
Hi,
I have a problem in receiving UDP broadcast data. We have a simple application which listens for the UDP broadcast data from the external servers. We can receive the UDP broadcast data from one of the servers. For the other external server, our program does not receive any data in the sockets, but we can see the broadcast data in tcpdump capture.
Is there any possible reason on why our sockets cannot receive the UDP broadcast, but the...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |