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