ELEG 651 and CPEG 419 – Project 1

Basic Socket Communication

  1. Write a client program that sends a "hello" to another host. And write a server program that waits for the "hello" and responds. Do this with both UDP and TCP. See UDP-info and TCP-info for a step-by-step guide on how to do this.
  2. Extend your client program to find all the "servers in a range" and tell them hello. That is, try to connect to an address, if the connection is successful (see what connect returns), then send the hello. By "servers in a range" has different meanings. Three examples are as follows
    1. The "servers in a range" could be the hosts in the Linux Lab in Evans 132. These machines have a range of IP address that range from 128.4.61.10 to 128.4.61.35. You can send hellos to each of these hosts by putting part of the server program in part A into a loop.
		for (i = 10; i<=35; i++) {
			sprintf(IPAddress,"128.4.61.%d",i);
			// the rest of your code
		}

This method will be useful for the next project. So, in preperation, you should implement it.

  1. Another way to define "servers in a range" is for them to be a set of servers on your machine with each server on a different port. Let suppose that you run your server on a few ports in the range of 10000 - 20000. Then you would have a loop that runs through this range ports and sends a hello to each server in this range. This approach is useful for testing your code on your own machine.
  2. The final way to define "servers in a range" is to provide a file that specifies all the possible IPs and ports that server applications might be. Then the client sends a hello to each host in the file. This technique will be used later in the semester, but code will be provided. So there is no need to implement this method. On the other hand, it other two methods are useful. But only one for this project, only one of these methods needs to be implemented.
In all cases, the server program should record each client program's hello message and gives its own response. The client program should record the response from the servers. Do this with both TCP and UDP.

 

What to turn in: This project consists of eight programs (two clients and two servers and for TCP and UDP). Turn in the code as well as well formated output generated by the programs. Since part A and B are so similar, just turn in 4 programs. The output should include the host and port communicated with or attempted as well as the message received. Messages should include the name of the author of the client/server.

For details on socket programming, see general socket info.