need help answering a few questions!!

This is a discussion on need help answering a few questions!! within the Linux Programming forums, part of the Platform Specific Boards category; I'm new to C and socket programming...please help answer the questions or show me some sites that might help answer ...

  1. #1
    Unregistered
    Guest

    need help answering a few questions!!

    I'm new to C and socket programming...please help answer the questions or show me some sites that might help answer my questions.

    #include <stdio.h>
    .
    .
    .
    #include <curses.h>
    #define POP3_PORT 110
    #define MAXLINE 255

    int pop_connect(char *);
    void pop_list();
    void pop_quit();

    main(int argc, char **argv)
    {
    char b[100];

    if(argc == 2)
    {
    pop_connect(argv[1]);
    }else{
    pop_connect("mail.yahoo.com");
    }

    getanswer();

    pop_authorization();

    pop_list();

    pop_quit();
    }
    int pop_connect(char *pophost)
    {
    int popsocket;
    struct sockaddr_in sin;

    /* What purpose does this structure serves?*/
    struct hostent *hp;

    /* What happens in the next line and how is it accomplished? */
    hp=gethostbyname(pophost);
    if(hp==NULL) return -1;

    bzero((char *)&sin,sizeof(sin));

    bcopy(hp->h_addr,(char *)&sin.sin_addr,hp->h_length);

    sin.sin_family=hp->h_addrtype;

    /* what occurs in the following line of code? */
    sin.sin_port=htons(POP3_PORT);


    if(popsocket==-1) return -1; popfd = popsocket;
    return popsocket;
    }

    void pop_list(void)
    {
    //how to write code for LIST command here
    }


    void pop_quit(void)
    {
    //how to write code for QUIT command here
    }

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Here's a good starter doc for sockets programming:

    http://www.ecst.csuchico.edu/~beej/guide/net/bgnet.pdf
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    Linux Socket Programming

    The best site for this subject
    REALLY GOOD!!!
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Couple of Questions
    By toonlover in forum Windows Programming
    Replies: 10
    Last Post: 07-14-2006, 01:04 AM
  4. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 07:42 AM
  5. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 08:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21