yes,is my code,its a run time error,and i am getting the error in the connect() function...i test it in linux,and iit works fine,but in windows it give sme this error.
Code:
Wsk::Wsk() :sock(-1)
{
memset(&addr , 0 , sizeof(addr));
#ifdef WINDOWS
if(WSAStartup(MAKEWORD(2 , 0) , &wsaData) != 0)
{
throw ExcepClass("Startup Failed");
}
#endif
}
Wsk::~Wsk()
{
::close(sock);
}
bool Wsk::create()
{
if((sock = socket(AF_INET , SOCK_STREAM , 0)) == -1)
{
return false;
}
else
return true;
}
bool Wsk::connect(const string host , const int port)
{
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
int status = ::connect(sock , (sockaddr * ) &addr , sizeof(addr));
if(status == -1)
{
cout << strerror(errno) << endl;
return false;
}
else
cout << "Connected to server"<< endl;
return true;
}