aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes UDP communication between C++ and Java does not work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "UDP communication between C++ and Java does not work" Watch "UDP communication between C++ and Java does not work" New topic
Author

UDP communication between C++ and Java does not work

M
Greenhorn

Joined: Jul 04, 2005
Posts: 1
Hi folks.

Currently I'm stuck on a very simple UDP communication protocol between a Windows MFC (VC++) application and a Java application.

I have a Java Server and a Java Client .. they communicate perfectly with each other.

The same on the C++ Side. Client and Server talk for hours with each other about lots of nonsense. ( currently about the meaning of life and 42 I think ;-) )

Only when I try to let any java program communicate with it's c++ counterpart - it fails !

Are there any additional "feature" I have to consider?

Here some more Details:

C++ part:

I tried Winsock as well as WinSock2.

with WSAStartup(..)
and socket(AF_INET, SOCK_DGRAM, 0);

Java part:

something with...

socket.connect(address, DAYTIMEPORT );
byte[] buf = new byte[DGRAM_BUF_LEN];
DatagramPacket packet = new DatagramPacket(buf, buf.length );
socket.send(packet);
socket.receive(packet);

Can anybody help me out?

Marco
Karen Baog
Ranch Hand

Joined: Mar 02, 2005
Posts: 120
Hi guys,

I'm also interested on this.
I'm new to UDP, but my task is similar to this.

I've posted a thread on UDP in the beginner's forum:

UDP

I will need to write an application in Java, which will communicate to 2 other applications (already) written in C++. My Java application basically "sits" between these 2 application, translating messages coming from one machine and forwarding it to the other machine.

I hope someone would provide an answer, and also to my question in the above link.

Thanks to all.

Karen


amerzil co-ed student<br />"Praise be the Code"
Willie McGee
Greenhorn

Joined: Jul 19, 2005
Posts: 3
what is the actual error you get?
Damaso Lopez
Greenhorn

Joined: Jun 21, 2012
Posts: 8
Willie McGee wrote:what is the actual error you get?


I've same problem,my case it send a buffer 1024 bytes in Java for UDP and received I've supposed 1024 in C but this application "C" says "Error UDP frame too smaill: 1024" I don't know that to do bad. My code is:


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UDP communication between C++ and Java does not work