| | |
UDP problem with C++ sendto() --> C# ReceiveFrom()
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2009
Posts: 1
Reputation:
Solved Threads: 0
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#:
C++:
Thanks in advance.
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#:
C# Syntax (Toggle Plain Text)
m_listenEp = new IPEndPoint(IPAddress.Any, m_Udplisten_port); m_UdpListenSocket = new Socket(m_listenEp.Address.AddressFamily, SocketType.Dgram, ProtocolType.Udp); m_UdpListenSocket.Bind(m_listenEp); m_sendEp = new System.Net.IPEndPoint(addr, m_Udpsend_port); m_UdpSendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); m_UdpSendSocket.SendTo(msgBuffer, msgBuffer.Length, SocketFlags.None, m_sendEp);
C++:
C++ Syntax (Toggle Plain Text)
SOCKET m_sfd; recvfrom(m_sfd,buf,maxLen,0,(struct sockaddr *)src, &fromlen); sendto(m_sfd,buf,len,0,(struct sockaddr *)src, sizeof(struct sockaddr_in));
Thanks in advance.
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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.
![]() |
Other Threads in the C# Forum
- Previous Thread: adding items in Combobox runtime in datagridview
- Next Thread: Combo box trouble
| Thread Tools | Search this Thread |
.net access algorithm array backup barchart bitmap box broadcast buttons c# check checkbox client clock combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees developer development draganddrop drawing dynamiccreation encryption enum excel file form format forms function gdi+ hospitalmanagementsystems httpwebrequest image index input install interface java label list listbox mandelbrot math microsystems mouseclick mysql operator password path photoshop picturebox pixelinversion post priviallages. programming property radians regex remoting richtextbox running... serialization server sleep soap socket sql sqlserver stack statistics stream string table temperature text textbox thread time timer update usercontrol validation visualstudio webbrowser windows windowsformsapplication winforms wpf write xml






