ctcptcpclient

TCP/IP Programming in C


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) ??


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.