Connect to a server made using JUCE from JAVA socket client

Hi Everyone,

We are trying to connect to a server made from JUCE using a socket connection and I need to pass an integer array to it. But when I checked the client code I noticed that the server is expecting the request to be of MemoryBlock type.
Here is the method on declaration on the server (void MainContentComponent::DemoInterprocessConnection::messageReceived (const MemoryBlock& message))

I have created a client socket in JAVA application which is using Jersey framework and connecting to the server made in C++ using JUCE

I am sending an integer array to the server but the client is not receiving it as it expecting MemoryBlock type as mentioned above.

So request help on how I can send this integer array of size 3 from my JAVA code to C++ server so that it takes it in MemoryBlock type.

MemoryBlock is the container holding the received data (regardless of the format sent). It will contain a buffer of a sequence of bytes. You will need to understand the format of the data being sent from the JAVA side, and unpack it accordingly. This information is likely available in the Jersey framework documentation. But if not, you could attempt to discern (reverse engineer) it by sending a known data set, putting a break point within messageReceived, and looking at the contents of the MemoryBlock buffer.

A quick look at the Jersey framework indicates that it is sending packets of ‘RESTful’ data, which looks to be an HTTP packet, with a JSON payload. JUCE contains classes for handling JSON, but I don’t know about handling the HTTP packet.

Depending on what your intention is, maybe the Jersey framework isn’t what you want. Maybe you just need a more simple sockets library?

1 Like

If you doing want to stick with Jersey, maybe this would be a good starting place for the JUCE side (link removed as code is not applicable, aka not even started)

Just had a look at jrlanglois/WebApi but that repository does not seem to contain any actual web code. There are only placeholder files on that repository it seems.

oh, how embarrassing… :frowning: jrlanglois is active on the board here, so I made the incorrect assumption it was a working piece of code.

Well, when i saw the name ‘jrlanglois’ i was making the same assumption, so no worries… i would like to see a JUCE based HTTP server as well. I know there are alternatives but it would be nice if this could become part of JUCE.

Until then this one might work:

The repo is quite active, so that’s always a good sign.