Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Hi, i have been trying to create a program that will connect to a server using its DNS name and have found out that i need to use the gethostbyname function. I also require it to read off a txt file that is stored there without the http headers and have not got a clue how to do it. When i compile my code using -gcc -Wall -ansi -pedantic -c client.c i get a load of errors. Would anyone be able to set me on the right path to makeing this work? the code that i am using is an example taken from a clint server program that i have tried to change.
/* Explicit declaration of an imported function. We could use a .h
for this. */
void readloop (int our_socket);
struct sockaddr_in our_address;
struct hostent* host_info;
/*Resolve the host*/
host_info = gethostbyname("host address");
if h_name == NULL
printf("/nError Connecting To Host");
if ((our_socket = socket(PF_INET, SOCK_STREAM, 0)) > 0)
printf("The socket has been created\n");
perror("Could not create socket");
our_address.sin_family = AF_INET;
if (argc < 2)
printf("Need one argument: the numeric IP address of the server!\n");
printf("Hopefully, %s is the numeric IP address of the server...\n",
/* No error checking on the next line -- hence the previous message! */
inet_pton(AF_INET, argv, &our_address.sin_addr);
our_address.sin_port = htons(23456);
(struct sockaddr *) & our_address,
sizeof(our_address)) == 0)
printf("Connected to host %s\n",
perror("Could not connect");
/* Insert read text file here */
if (close(our_socket) != 0)
herror("Warning: problem closing our_socket");
You have many syntax mistakes like not closing }, forgetting to put () in functions. Those are really easy to correct and you should do this by yourself, since you are a C newbie.
A newbie C network programming guide is here: http://www.ecst.csuchico.edu/~beej/guide/net/html/
It contains an example of a simple server client model. Also use spaces and tabs when nesting something .It will be a lot easier to correct syntax mistakes. it's easier to see if a branket is missing, when writing like this: