View Single Post
  #1 (permalink)  
Old 06-20-2008, 08:23 AM
bodhi2016 bodhi2016 is offline
Newbie
 
Join Date: Jan 2008
Posts: 29
Credits: 0
Rep Power: 4
bodhi2016 is on a distinguished road
Default Problem with the server software

I have made the a portion of the server software(i did it till the bind portion) .
Code:
#include<windows.h>
#include<iostream.h>
int main()
{
    WSAData wsadata;
    if (WSAStartup(MAKEWORD(2,0),&wsadata)!=0);
       {cout<<"winsock startup  failed\n"<<WSAGetLastError();
       WSACleanup();
       return -1;
       }
     cout<<"winsock startup is succes\n";
     SOCKET servsock=socket(AF_INET,SOCK_STREAM,0);
     if(servsock ==INVALID_SOCKET)
     {cout<<"socket init failed\n";
     return -1;
     }
    cout<<"socket init\n"; 
    sockaddr_in sin;
    sin.sin_port=htons(80);
    sin.sin_addr.s_addr=INADDR_ANY;
    sin.sin_family=AF_INET;
    if (bind(servsock,(sockaddr*)&sin,sizeof(sin))==SOCKET_ERROR)
    {cout<<"FAILED TO BIND"<<WSAGetLastError();
    WSACleanup();
    return -1;
    }
    std::cout<<"Bind successful!\n";
    WSACleanup();
    return 0;
}
I usually compile my programme from time to time .When i compiled the above code i got many errors but i was able to tackle them but few error i cant do away with are these one:-
--------------------------------------------------------------------------
32:2 D:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h multiple definition of `main'
32:2 D:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h first defined here
32:2 D:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h ld returned 1 exit status
--------------------------------------------------------------------------
Void or methodz can you please tell me where i am going wrong
Thank You
Reply With Quote

Sponsored Links