Question

I have a problem in my C client, where I implemented a client gsoap program to invoke a web service.

Everything works fine on a Windows PC, but when I publish my code on a linux-based POS device, I receive the following error:

"setsockopt SO_SNDBUF failed in tcp_connect()"

Where should I start to debug this error, what could be the cause?

the errornum returned is 2

The code section that generates the error : (in stdsoap2.c)

 if (setsockopt(sk, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))){
    soap->errnum = soap_socket_errno(sk);
    soap_set_sender_error(soap, 
                          tcp_error(soap), 
                         "setsockopt SO_SNDBUF failed in tcp_connect()",
                          SOAP_TCP_ERROR);
    soap->fclosesocket(soap, sk);

#ifdef WITH_IPV6
    freeaddrinfo(ressave);
#endif
    return SOAP_INVALID_SOCKET;
  }
Was it helpful?

Solution 2

well it turned out to be very simple one!!

i just had to build the c/c++ files using the binaries dedicated for linux....

gsoap(wsdl2h,soapcpp2)

windows build uses winsock and linux build uses standard sockets and the sockets on the 2 systems are differentes!

thats why i was receiving the socket error.

hope this help others, getting this socket error msg..

OTHER TIPS

How big is the len argument? It's possible that the value works on Windows, but is rejected by linux for some reason. Take a look at the actual values being submitted and see if they look reasonable.

You can also try reducing this down to a very small program that just sets up a socket and tries to replicate the call to setsockopt() and see if it still fails with the SO_SNDBUF size the main program is trying to use.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top