You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Patrick Willart <pa...@aptitudexchange.com> on 2003/10/03 01:58:59 UTC

cgi program cannot open a new socket - security issue ?

I have a (legacy) cgi program that tries to open a TCP IP socket to a
certain address port for communication. On Apache and iPlanet the CGI
program works fine. On Tomcat however the CGI program isn't able to open the
socket and returns an error.

This call fails with error 10106 (WSAEPROVIDERFAILEDINIT):
SOCKET sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

I am running Tomcat 4.1.18 on Windows 2000 without the security manager
enabled. On the same machine it works fine with the other servers.

Could this be a security issue or has anybody an idea of what is going
wrong?

Below is the complete method:


SOCKET SocketConnect(const char* hostname, unsigned short port) {

	struct sockaddr_in	dest;

	if (!bInitialised) {
		if (WSAStartup(MAKEWORD(2,1), &wsaData) != 0)
			return INVALID_SOCKET;
	}

	if (!translateIpAdress(dest, hostname, port))
		return INVALID_SOCKET;

	SOCKET sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

	if(::connect(sock, (SOCKADDR*)&dest, sizeof(dest)) == SOCKET_ERROR)
		return INVALID_SOCKET;

	return sock;
}


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org