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
}