943,553 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 576
  • C RSS
Apr 14th, 2009
0

Compiling a Server Program

Expand Post »
Hello, all!

I'm trying to understand how a client/server would work, and I found a server example I could play with on the internet. However, I can't get it to compile due to a bunch of undefined variables (sendto, socket, etc).

Are there some options I should include in the command line when I compile?

Thank you

- Jim
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
JimD C++ Newb is offline Offline
46 posts
since Oct 2008
Apr 14th, 2009
0

Re: Compiling a Server Program

Could you link to the example? First thing that springs to mind is that the example was made for a different platform (UNIX v WIndows) and the headers are not being found. But without more info I dunno.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
krellor is offline Offline
12 posts
since Dec 2008
Apr 14th, 2009
0

Re: Compiling a Server Program

Sure!

http://beej.us/guide/bgnet/output/ht...l#simpleserver

It's the 'listener' example

Also was looking at the 'server' example

Thank you

- Jim
Reputation Points: 10
Solved Threads: 0
Light Poster
JimD C++ Newb is offline Offline
46 posts
since Oct 2008
Apr 14th, 2009
0

Re: Compiling a Server Program

Ok, so it looks like that code is for UNIX. Are you running windows? If you are you can try this C socket tutorial:

http://www.shadowsprite.com/shadowsp...code&Itemid=56

and the full code at:

http://www.shadowsprite.com/shadowsp...=36:c&Itemid=1


I apologize if you are not using windows. If you are using *nix, what distro?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
krellor is offline Offline
12 posts
since Dec 2008
Apr 14th, 2009
0

Re: Compiling a Server Program

I am running it on my school's frodo if that helps
Reputation Points: 10
Solved Threads: 0
Light Poster
JimD C++ Newb is offline Offline
46 posts
since Oct 2008
Apr 14th, 2009
0

Re: Compiling a Server Program

i dont think anyone knows what your schools frodo is.

simple answer: run sockets on Unix/Linux using teh <sockets.h> library.

run socket programs on windows using the <winsock.h> library.

the rest is just details.
Reputation Points: 2143
Solved Threads: 178
Posting Maven
jephthah is offline Offline
2,567 posts
since Feb 2008
Apr 14th, 2009
0

Re: Compiling a Server Program

Frodo as in the commodore 64 emulator?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
krellor is offline Offline
12 posts
since Dec 2008
Apr 14th, 2009
0

Re: Compiling a Server Program

No not the Commodore 64 emulator - it is a Unix system that we can telnet into
Reputation Points: 10
Solved Threads: 0
Light Poster
JimD C++ Newb is offline Offline
46 posts
since Oct 2008
Apr 14th, 2009
0

Re: Compiling a Server Program

To be honest, I've never heard of it. Obviously it is not finding the header files. You might need to ask your sysadmin what steps you need to take to compile C in your working directory, or to make the headers available. Barring that, just burn Ubuntu or Knoppix and use their Live CD mode to play around in a *nix environment. Although if all you are trying to do is figure out client/server socket communication, just look at the windows ready code in the links above and compile it on your windows machine (I assume Windows since you say you are telneting into a UNIX environment).
Reputation Points: 10
Solved Threads: 0
Newbie Poster
krellor is offline Offline
12 posts
since Dec 2008
Apr 14th, 2009
0

Re: Compiling a Server Program

^ you havent heard of Unix? or his schools' particular implementation? most unix systems are named. it's just a geek thing. his school's is named Frodo. Mine was named Eos. ive seen others such as "Dante" or even more recently, "Quidditch". i figured that was what he was talking about, but it's not particularly useful to refer it to people who dont go to your school.


^^ anyhow, JimD, those variables you refer to are defined in the header files such as /sys/socket.h, /arpa/inet.h ... if your program cant find those #defines, then maybe those libraries are not being made available to you on your system, or they're in an unusual location.

IIRC, my undergrad program did not allow people to set up servers on the campus unix system.

so, if you're having trouble, i'm not surprised. i doubt you'd be able to set up a server/client even within your unix network, and i'm certain you won't be able to do it remotely.

try using it on your home computer instead.

you can run the server and client on the same machine, and use the localhost IP. But a more interesting example would be if you have two machines (say a laptop and a desktop) networked through a home router.
Last edited by jephthah; Apr 14th, 2009 at 7:32 pm.
Reputation Points: 2143
Solved Threads: 178
Posting Maven
jephthah is offline Offline
2,567 posts
since Feb 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Sorting without an array
Next Thread in C Forum Timeline: Processing keystrokes from keyboard





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC