Question

I have an exam on tomorrow on TCP/IP programming. Following is one of the previous question on this paper.

Write and run a client and a server program. Using C language in UNIX, with the
following specifications :

• A TCP client program will send a range of number (e.g. 1 to 10) to the server.
• TCP server accept the number range from client and send back the sum of the
number range. Client will print the result.

I dont know how to setup the compiler and other settings to run this tcp ip programs. When I search online, I got two different programs, one for Client and another For server. Some please tell me how can i run these programs to get desired output. What kind of compiler should I install on my system.( I am using windows 7) ??

Was it helpful?

Solution

Since the assignment requires your code to work on a Unix system, you first need to install one. Follow these simple steps to install a virtual Unix environment on top of your existing Windows installation.

  1. Download and install VirtualBox for Windows.
  2. Download & unpack this Ubuntu 12.10 disc image (NOTE: Requires 7-Zip).
  3. Launch VirtualBox and create a new Virtual Machine (name it Ubuntu).
  4. In the "Virtual Hard Disk" settings, select "Use existing hard disk" and select the image file you just downloaded (NOTE: It's filename should end in ".vdi").
  5. Run your new Virtual Machine. You should see the Ubuntu splash screen.
  6. Login with username ubuntu and password reverse (NOTE: Case Sensitive!).
  7. Open up Terminal and type sudo apt-get install build-essential (NOTE: when Terminal prompts you for a password, use reverse).
  8. You should (with hope) have everything you need for your assignment. For more information on network programming, consult Beej's Guide to Network Programming -- Using Internet Sockets.

OTHER TIPS

You need to open two different terminals on your system. In the first terminal compile and run the server.c program.(make sure either you listen to all ips or your host ip(atleast). while this is running.(it will wait for a request from your client program) Run the client program in the other terminal.

Hope this solves the problem!

For details on how to create and run a file in unix refer http://www.wikihow.com/Compile-a-C-Program-Using-the-GNU-Compiler-%28GCC%29

P.S: you can do the same in win7 if iam not wrong only that terminal here in called command prompt!

Post the results if possible!

Download a thing called VMWare player. And look for a Ubuntu image that you can load with the VMWare player. That way, you will have a little Linux virtual machine that you can run inside or along with Windows 7. You can use the compiler GCC in your Ubuntu or whatever other Linux virtual machine. And get lots of coffee. Blargle is correct, but I think my suggestion is a little better, because you end up having a fairly complete Unix type environment to develop in. Blargle's way put Unix tools on top of Windows, which I find to be kind of clunky.

I learnt socket programming from this site. He has given everything in detail . Download an Vmware workstation and load up ubuntu . Understand the programs they are pretty much straight forward .

Maybe you can try to look at Network Socket on the web. You can easily find a lot of good tutorial that can answer your question.

You can use the compiler you want on your system, depending on what are you using now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top