Thread: socket error

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    227

    socket error

    I am tring to create a program that will let me loggin to irc... but.. i keep getting

    Connecting to server...
    NOTICE AUTH :*** Looking up your hostname.....
    NOTICE AUTH :*** Checking Ident
    NOTICE AUTH :*** Found your hostname
    NOTICE AUTH :*** Got Ident response

    ERROR :Closing Link: [[email protected]]

    well i made it that far to get it connected.. but it wont give me all the info that it should.. so that i can join a chan etc..

    anyways.. here is the code ( please take it easy im new to socket and am really stressed about not remembering somethings so streesed i can cry)

    Code:
    #define MYPORT 6667
    
    int main( )
    {
    
        struct sockaddr_in mysock;
         struct sockaddr_in tosock;
         struct hostent *addr;
         int s_sock, s_conn, x;
         int len, s_send, s_recv;
         char *p_buff, buff[525];
         char *msg;
         
         
         if((s_sock = socket( AF_INET, SOCK_STREAM, 0 )) == -1 )
         {
           fprintf( stderr, "Error on SOCKET( )" );
            return 1;
         }
         
        /* fgets( buff, 20, stdin );
         printf("xlordt suxz 1\n");
         */
         mysock.sin_family = AF_INET;
         mysock.sin_port = htons( MYPORT );
         mysock.sin_addr.s_addr = inet_addr( "66.252.6.72" );
         
         if((s_conn = connect( s_sock, ( struct sockaddr *)&mysock, sizeof mysock)) == -1 )
         {
            fprintf( stderr, "Error on SOCKET( )" );
            return 1;
         }
         
         printf( "Connecting to server...\n" );
         
         p_buff = buff;
         p_buff = (char *)malloc( 64 * sizeof( char ));
         for( x=0; x < 25; x++ )
         {
           if((s_recv = recv( s_sock, p_buff, sizeof p_buff, 0 )) == -1 )
           {
              fprintf( stderr, "Error on RECV( )" );
              return 1;
           }
           
       
           printf( "%s", p_buff );
           msg = "PING";
           len = strlen( msg );
           send( s_sock, msg, len, 0 );
           recv( s_sock, p_buff, sizeof p_buff, 0 );
           printf( "%s", p_buff );
           
         }
        
         
         msg="/nick hmmmm";
         len = strlen( msg );
         
         if((s_send = send( s_sock, msg, len, 0 )) == -1 )
         {
            strerror( errno );
            return 1;
         }
         
         msg="/join #chan";
         len = strlen( msg );
         
         if((s_send = send( s_sock, msg, len, 0 )) == -1 )
         {
            strerror( errno );
            return 1;
         }
         
         return 0;
         
         close( s_sock );
      }
    I am just going crazy tring new $$$$ here.. =/
    Last edited by xlordt; 09-24-2003 at 10:52 PM.
    Only the strong survives.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM