I'm trying to make a simple socket client (using debian 6 and g++ compiler) and when I'm calling "connect" function, it returns error code 22 - Invalid argument. Tell me, what am I doing wrong, please.
I've read the man page for this function and it says that the 3 arguments must be as followed: int, struct sockaddr* and socklen_t.
My code is:
int serverPort;
u_long serverHost;
struct sockaddr_in serverAddress;
socklen_t serverAddressLength;
int clientSocket;
serverPort = 44444;
serverHost = inet_addr ( "88.198.237.65" );
serverAddress.sin_family = AF_INET;
serverAddress.sin_port = htons ( serverPort );
serverAddress.sin_addr.s_addr = htons ( serverHost );
serverAddressLength = sizeof ( serverAddress );
clientSocket = socket ( AF_INET , SOCK_STREAM , 0 );
connect ( clientSocket , (sockaddr*)&serverAddress , serverAddressLength )