Lab 1 CS Majors

Objective

The objective of this lab is to familiarize the student to the development environment on Linux for writing networking code using sockets. This will be done by implementing and testing the code in the later part of the text, Chapter 1.

Method

Create two files, server.cpp and client.cpp. Enter the code as seen in the text. As the code is written it will not compile, as several includes are missing for Linux. I found the following includes to all be needed for client.cpp:

#include <stdio.h>
#include <strings.h>
#include <cstring>
#include <cstdlib>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>

I found the following includes needed for server.cpp:

File Edit Options Buffers Tools C++ Help                                        
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

Also, the len variable in server.cpp needs to be of type socklen_t, eg:

socklen_t len;
In addition, create a single Makefile to to build both of these files.

Test out the code between to different systems in the lab. You will need to cooperate with another student to do this.

Turn in

  1. (30%) The code
  2. (10%) The Makefile,
  3. (30%) A capture of the working operation.
  4. (30%) A paragraph discribing your experience, including any difficulties encountered and suggestions for improvement.
-- JimSkon - 2011-09-13
Topic revision: r5 - 2013-07-15 - JimSkon
 
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback