CM10228 / Programming Ib:   Lab 2

Concurrency and Networking: Networking

<< Back to contents

Background:

You probably already know what networking is. In fact, you almost certainly used networking to read this file, by downloading it off the Internet. You may not know how simple networking really is, at least to incorporate into our own programs. When it comes to our applications, networking really just has two components. 1) pass some data over a network, 2) set up some protocol so you know how to interpret the data that you are receiving (and you know what to send in response). Of course, the technical details of part 1 are more complicated than that, but when it comes to actually networking in Java, just like many other concepts like data structures or concurrency, all the hard work has already been done for us. We just need to know how to use the tools.

Do this:

Now you know the basics of networking. You have built a client and a server, and they communicate by just sending messages backwards and forwards. Now we go back to the EchoClient from point 2.

Now you should have a client that connects to a server. At the moment the server is just repeating what the client says, which is fine. This still shows two points, 1) networking is simple, most of the work is done for you in Java, and 2) the messages being sent backwards and forwards are just text. You may need a protocol, but the communication itself is nothing more complicated.

We are now going to combine the last two sections and show you why you need concurrency to properly use networking.

Concurrency Meets Networking >>



page author: Andrew Chinery
last updated: 01 March 2013