UDP problem with C++ sendto() --> C# ReceiveFrom()

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2009
Posts: 1
Reputation: VRspace4 is an unknown quantity at this point 
Solved Threads: 0
VRspace4 VRspace4 is offline Offline
Newbie Poster

UDP problem with C++ sendto() --> C# ReceiveFrom()

 
0
  #1
Mar 9th, 2009
Hello,

I'm writing a simple C# connectionless UDP application that communicates with a C++ connectionless UDP app. I could send from the C# to C++ using the following sets of functions fine:

Send from C# to C++
C#: SendTo()
C++: recvfrom()

However, I'm having trouble receiving the C++ UDP messages from the C# application. The recvfrom() from the C++ app appears to be generating random source information, which is then used as the destination for the sendto() C++ function.

The limitation is that I can only make changes to the C# application and not the C++'s. Below is how I implemented the UDP for both C# and C++ app.

C#:
  1. m_listenEp = new IPEndPoint(IPAddress.Any, m_Udplisten_port);
  2. m_UdpListenSocket = new Socket(m_listenEp.Address.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
  3. m_UdpListenSocket.Bind(m_listenEp);
  4.  
  5. m_sendEp = new System.Net.IPEndPoint(addr, m_Udpsend_port);
  6. m_UdpSendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
  7.  
  8. m_UdpSendSocket.SendTo(msgBuffer, msgBuffer.Length, SocketFlags.None, m_sendEp);

C++:
  1. SOCKET m_sfd;
  2. recvfrom(m_sfd,buf,maxLen,0,(struct sockaddr *)src, &fromlen);
  3. sendto(m_sfd,buf,len,0,(struct sockaddr *)src,
  4. sizeof(struct sockaddr_in));

Thanks in advance.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: UDP problem with C++ sendto() --> C# ReceiveFrom()

 
0
  #2
Mar 10th, 2009
UDP stuff is always harder to work with as you cant guarentee its arrival. Have you tried a packet sniffer on the recieving end to ensure its getting there?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC