Hi, Im trying to program a client/server on two different computers, and make them connect, by using "SSL client example" and "SSL server example" (which are chilkat products), but they are not connecting. even though I've changed the sslServerHost (client-side) to the server's IP address. And I even turned off the AntiViruses on both computers.
NOTE: Im using Wi-Fi, and when I checked the IP address of both computers, they were the same. can this be the problem???? What shall I do!
The Server-Side Code:
void Server(void)
{
cout<<"Server-Side\n";
cout<<"===========\n\n";
CkSocket listenSslSocket;
bool success;
success = listenSslSocket.UnlockComponent("**********************");
if (success != true) {
printf("%s\n",listenSslSocket.lastErrorText());
return;
}
CkCertStore certStore;
success = certStore.LoadPfxFile("/Users/rania/My Documents/DIGITAL CERTIFICATES/MServer.pfx","***********");
if (success != true) {
printf("%s\n",certStore.lastErrorText());
return;
}
CkCert *cert = 0;
cert = certStore.FindCertBySubject("MServer");
if (cert == 0 ) {
printf("%s\n",certStore.lastErrorText());
return;
}
success = listenSslSocket.InitSslServer(*cert);
if (success != true) {
delete cert;
printf("%s\n",listenSslSocket.lastErrorText());
return;
}
delete cert;
long myPort;
myPort = 5555;
long backLog;
backLog = 5;
success = listenSslSocket.BindAndListen(myPort,backLog);
if (success != true) {
printf("%s\n",listenSslSocket.lastErrorText());
return;
}
listenSslSocket.put_MaxReadIdleMs(10000);
listenSslSocket.put_MaxSendIdleMs(10000);
CkSocket *clientSock = 0;
long maxWaitMillisec;
maxWaitMillisec = 20000;
clientSock = listenSslSocket.AcceptNextConnection(maxWaitMillisec);
if (clientSock == 0 ) {
printf("%s\n",listenSslSocket.lastErrorText());
return;
}
const char * receivedMsg;
receivedMsg = clientSock->receiveUntilMatch("-EOM-");
if (receivedMsg == 0 ) {
printf("%s\n",clientSock->lastErrorText());
return;
}
printf("%s\n",receivedMsg);
success = clientSock->SendString("Hello Client! -EOM-");
if (success != true) {
printf("%s\n",clientSock->lastErrorText());
return;
}
clientSock->Close(20000);
delete clientSock;
}
The client-Side code:
<pre lang="cs">void Client(void)
{
CkSocket socket;
bool success;
success = socket.UnlockComponent("*************************");
if (success != true) {
printf("%s\n",socket.lastErrorText());
return;
}
bool ssl;
ssl = true;
long maxWaitMillisec;
maxWaitMillisec = 20000;
const char * sslServerHost;
sslServerHost = "188.249.158.247";
long sslServerPort;
sslServerPort = 5555;
success = socket.Connect(sslServerHost,sslServerPort,ssl,maxWaitMillisec);
if (success != true) {
printf("%s\n",socket.lastErrorText());
return;
}
socket.put_MaxReadIdleMs(20000);
socket.put_MaxSendIdleMs(20000);
success = socket.SendString("Hello Server! -EOM-");
if (success != true) {
printf("%s\n",socket.lastErrorText());
return;
}
const char * receivedMsg;
receivedMsg = socket.receiveUntilMatch("-EOM-");
if (receivedMsg == 0 ) {
printf("%s\n",socket.lastErrorText());
return;
}
socket.Close(20000);
printf("%s\n",receivedMsg);
}
Best Regards.
Rania