ok here's one part of my code...
Code:
int main(int argc, char **argv)
{
int sock;
int port, queryCode, length;
int clientSock;
char message[260];
struct sockaddr_in servSock_in;
struct sockaddr_in client_in;
char *serverIP; //the IP of the FTP server
char *hostname;
debug = 0; //debug is OFF by default
port = 53000;
if(argc == 2)
{
if( strcmp(argv[1], "1") == 0 )
{
debug = 1; //debug mode is ON
printf("debug mode is ON\n\n");
}
}
sock = socket(PF_INET, SOCK_DGRAM,0); //the dns server socket
if ( sock< 0)
{
printf("I am too tired... I failed to open gate...\n");
return -1;
}
memset((char *)&servSock_in,0,sizeof(servSock_in));
servSock_in.sin_family = PF_INET;
servSock_in.sin_addr.s_addr = htonl(INADDR_ANY);
servSock_in.sin_port = htons((u_short)port);
//bind server
if (bind(sock, (struct sockaddr *)&servSock_in, sizeof(servSock_in)) < 0)
{
printf("I couldn't attach gate to port...\n");
return -1;
}
else
printf("Waiting for messages...\n");
you asked me about blocking or non blocking sockets..actually I don't know the difference between them (i'm new in network programming..)