Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Net/TFTP/main.cpp

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////
00002 // SunOS: g++ main.cpp -o udp -lpthread -lsocket -lnsl
00003 // Linux: cc  main.cpp -o udp -lpthread
00004 // Win32: cl  main.cpp -o udp.exe  (for Microsoft compiler)
00005 ///////////////////////////////////////////////////////////////
00006 
00007 
00008 #include <j2k/Fred/Standard.hpp>
00009 #include <j2k/Net/UDP/UDP_all.cpp>
00010 #include <j2k/Net/TFTP/TFTP_Option.hpp>
00011 
00012 int main( int argc, char* argv[] )
00013 {
00014    char buf[ BUFFER_SIZE ];
00015    short listeningport;
00016    short destport;
00017    char* desthost;
00018 
00019    if(  ( argc != 4 ) ||
00020        !( listeningport = atoi(argv[1]) ) ||
00021        !(      destport = atoi(argv[3]) )  )
00022    {
00023       printf("Usage: udp [listen port number] [destination machine] [destination port]\n");
00024       return 0;
00025    }
00026 
00027    desthost = argv[2];
00028 
00029    option.ArgParser( argc, argv );
00030 
00031    option->sender = new UDP_SocketClient( srvAddr, port );
00032 
00033    UnixSocketReceiver Receiver( listeningport );
00034    UnixSocketSender   Sender( desthost, destport );
00035 
00036    if ( Receiver.Listen() == NULL )
00037    {
00038       printf("Error listening to UDP port\n");
00039       return 0;
00040    }
00041 
00042    Sender.setSocket( Receiver.getSocket() );
00043 
00044    while(  fgets( buf, sizeof(buf), stdin )  )
00045    {
00046       Sender.SendMsg( buf, strlen(buf) );
00047    }
00048 
00049    return 0;
00050 }
00051 
00052 
00053 
00054 
00055 
00056 

Generated on Sun Oct 14 18:46:18 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001