Listening to Port


#1

Hello,

I need to listen to HTTP port 9090 for incoming messages.
I am a Newbie on this and would like to know whether the StreamingSocket class is
the one I need to use. If so, how do I get informed about incoming stuff?
Is there a callback or something? The server on the other end is not a juce app.

Thanks
Joerg


#2

Hello,

yes the Streaming socket is ´the right one for you.

You need a listener class like.

StreamingScket listenerSocket;

listenerSocket.createListener( 9090, String::empty);

StreamingSocket * newConnection = listenerSocket.waitForNextConnection();

The problem here.‘waitForNextConnection’ is blocking, so the best way is running in a worker thread.
and a new connection is signalled with callback, interfaces etc.

For the new connection you need a new class that handle all stuff for this new HTTP connection.
Here the same, create a thread and start the read function from the streaming socket. This is a blocking
call and for each successfully read, call a signal function for the incomming data to your HTTP server instance.

You write "the server on the ends is not a Juce App "., so I assume you need an DLL interface for the Juce stuff.

regards
mathias


#3

Thanks Mathias! I’ll give it a go.

You write "the server on the ends is not a Juce App "., so I assume you need an DLL interface for the Juce stuff.

What do you mean with that? Do I need to have a juce-based sender on the other end?

Thanks
Joerg