LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Result to large error in c++ (https://www.linuxquestions.org/questions/programming-9/result-to-large-error-in-c-797764/)

vbx_wx 03-25-2010 05:37 AM

Result to large error in c++
 
I am getting this error when i try to connect a client to a server in windwos ,anybody knows why ?

graemef 03-25-2010 08:58 AM

I think that you need to provide a little more information.

Is this a program that you have written?
If so what is the appropriate code.
If not what program are you using?
Is it a compile time or a run time error?
Can you provide a little more detail about the error, and what you were expecting to see.

cola 03-25-2010 10:43 AM

Quote:

Originally Posted by vbx_wx (Post 3911565)
I am getting this error when i try to connect a client to a server in windwos ,anybody knows why ?

Post complete code.

vbx_wx 03-25-2010 10:44 AM

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;
        }



All times are GMT -5. The time now is 10:22 AM.