| | |
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 barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom cyclethruopenforms data database datagrid datagridview dataset date/time datetime degrees development dll draganddrop drawing encryption enum event excel file finalyearproject form format forms function gdi+ getoutlookcontactusinfcsvfile globalization httpwebrequest image index input install installer java label list listbox mandelbrot math mono mouseclick mysql operator panel path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox save server silverlight sleep socket sql sql-server statistics stream string table text textbox thread time timer timespan update usercontrol users validate validation visualstudio webbrowser wia windows winforms wpf xml






