tags:

views:

151

answers:

3
#include "ServerSocket.h"
#include "SocketException.h"
#include <string>
#include<iostream>

int main(int argc, int argv[])
{
  std::cout << "running....\n";

  try
  {
      // Create the socket
      ServerSocket server ( 30000 );

      while ( true )
      {
           ServerSocket new_sock;
           server.accept ( new_sock );
           try
           {
               while ( true )
               {
                   std::string data;
                   new_sock >> data;
                   new_sock << data;
               }
           }
           catch ( SocketException& ) {}
        }
    }
    catch ( SocketException& e )
    {
        std::cout << "Exception was caught:" << e.description() << "\nExiting.\n";
    }

    return 0;
}
+1  A: 

The signature for main should be:

int main(int argc, char **argv)

or

int main(int argc, char *argv[])
Matt Joiner
thanks the problem hav been resolve
Raja
+1  A: 

replace: int main(int argc, int argv[])

with: int main(int argc, char* argv[])

SuperShabam
+2  A: 

Honestly,

int main(int argc, int argv[]) 

is nonsense. Where did you find that?

This is the second question with the almost exact same title that is completely unrelated to socket programming. Do not try to do socket programming if you don't have a running hello world application.

This question is not related to linux nor to sockets, this is plain c++.

mnemosyn