Hi
I have installed STunnel version 5.xx and using a TCP client to connect with it but no success. My details are as follows:
1. Configuration of STunnel.conf
verify = 3 CAfile = peer-LMAX-fix-tunnel-DEMO-MktData.pem
[LMAX-fix-tunnel-DEMO-MktData] client = yes accept = 127.0.0.1:40003 connect = fix-md-ate.lmaxtrader.com:443
cert = stunnel.pem key = stunnel.pem socket = l:TCP_NODELAY=1 socket = r:TCP_NODELAY=1
Certificate file stunnel.pem was generated by software itself.
2. I have written a TCP client as follows:Only part of code is given below
*********************************************** // Resolve the server address and port iResult = getaddrinfo("127.0.0.1", 40003, NULL, &servinfo);
// Attempt to connect to an address until one succeeds for(ptr=servinfo; ptr != NULL ;ptr=ptr->ai_next) {
// Create a SOCKET for connecting to server ConnectSocket = socket(ptr->ai_family,ptr->ai_socktype,ptr-ai_protocol);
// Connect to server. iResult = connect( ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen); break; }
// Send an initial buffer iResult = send( ConnectSocket, sendbuf, (int)strlen(sendbuf), 0 );
printf("Bytes Sent: %ld\n", iResult);
// Receive until the peer closes the connection do {
iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0); if ( iResult > 0 ) printf("Bytes received: %d\n", iResult); else if ( iResult == 0 ) printf("Connection closed\n"); else printf("recv failed with error: %d\n", WSAGetLastError());
} while( iResult > 0 );
******************************************************** Here I would like to tell you that I have used 127.0.0.1 and 40003 in getaddrinfo and same has been configured in conf file.
Whenever I try to connect I am receiving iResult =0 from recv().
Could anybody please let me know is there anything wrong with my configuration and how to get resolve the current issue?