File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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

UDP communication between C++ and Java does not work


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 );

Can anybody help me out?

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:


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.


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

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

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:

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: UDP communication between C++ and Java does not work
It's not a secret anymore!