Question about InterProcessServer & StreamingSocket


#1

Hi,

I’ve two little question about the Interprocess classes and particulary about the StreamingSocket class ?

I want to generate a TCP tunnel between my application and a distant web-service on a dedicated online server. For the moment, all is theorical and i’ve made some local test between two process, one calling another and using local ip : 192.168.100.xxx on port 443 (for testing). No problem. But my question is about a non-local network, if my app call a fixed ip of a distant server can I connect a Juce app installed on ?

I’ve read some topics on the forum talking about the cURL library. I think it’s a good solution for support a lot of protocols and working together with openSSL. My other question is about the method waitForNextConnection ();

//=============================================================================
#include "SocketService.h"
#include "RSAKeyGen.h"
//=============================================================================
SocketService::SocketService ()
	: StreamingSocket (),
	  Thread (String::empty),
	  database (),
	  skewTime (0.0),
	  numCall (0)
{
	onStart ();
}
//=============================================================================
SocketService::~SocketService ()
{
	onStop ();
}
//=============================================================================
void SocketService::onStart ()
{
	KeyGen::testCurveParameters ();

	cout << "Key Generator (4 Pairs for testing)" << endl;
	cout << "---------------------------------------------------------------------" << endl;
	for (int i=0; i < 4; ++i)
	{
		const int64 b = Time::currentTimeMillis ();
		RSAKeyGen::generatePair ();
		const int64 a = Time::currentTimeMillis ();
		const String differential = (RelativeTime::milliseconds(a)-RelativeTime::milliseconds(b)).getDescription ();
		cout << "---------------------------------------------------------------------" << endl;
		cout << "Time to compute: " << differential.toUTF8() << endl;
		cout << "---------------------------------------------------------------------" << endl;
	}
	//database.connection();
	//crypto.setAlgorithm (SocketCrypto::CRYPT_RIPEMD320);

	if (StreamingSocket::createListener (PORTNUMBER))
	{
		startThread (8);
	}
}
//=============================================================================
void SocketService::onStop ()
{
	stopThread (1000);
}
//=============================================================================
void SocketService::run ()
{
	while (!threadShouldExit())
	{
		Thread::sleep (jlimit(10, 100, 40-(int)skewTime));
		const double b = Time::getMillisecondCounterHiRes ();

		StreamingSocket *connection = StreamingSocket::waitForNextConnection ();
		if (connection)
		{
			const ScopedLock sl (cs);
			numCall++;
			threads.add (new SocketThread(connection));
		}

		const double a = Time::getMillisecondCounterHiRes ();
		skewTime = a - b;
	}
}
//=============================================================================

This is a basic testing class, a little InterprocessServer-like. When the server catch a connection a new thread start to manage the socket. I want to move the connection to another port, maybe by using bindToPort () ? But when I use it in my SocketThread class i’ve a error (return bool to false). Don’t know why ?

So my question is about this point. The listener in the SocketService class get a new StreamingSocket (TCP on 443). Can I use this one with cURL in the SocketThread ? I get the host (ip) and port of the client-side. Maybe I can close the Juce socket and call the application in another random port in a specific range ?

If someone have information about theses questions, I will be very happy to read that :wink:


#2

Understand me. All of that can be tested by myself. But I need a dedicated server that I will buy in few months. In other case, my actual mutual server can’t allow to execute application on.

No one ?


#3

My network ‘skillz’ aren’t really up to answering your question, I’m afraid…


#4

Hi,
I’ve tested the Interprocess classes with a real Server (not on my local machine) and it was pretty easy to make my local juce app talk to a juce app on the web server on an arbitrary port.
Nevertheless I’m currently using the “boost c++ asio” classes together with the openSSL library, because I needed SSL for the communication. It took me some time to be familiar with boosts’ template style, but it works great and both openSSL and boost are free.

Hope this helps.


#5

[quote=“friscokid”]Hi,
I’ve tested the Interprocess classes with a real Server (not on my local machine) and it was pretty easy to make my local juce app talk to a juce app on the web server on an arbitrary port.[/quote]

Hi friscokid ! And you’ve the answer :slight_smile: I’m happy to hear that!

I’m not very experiment with boost library but a quick look in the boost website show me is all that I need.

A Great Help ! Thanks a lot !