examples.example2_one_client_OO
Class Main
java.lang.Object
examples.example2_one_client_OO.Main
public class Main
- extends Object
NetworkingExamples project: examples.example2_one_client_OO.
A simple example of networking (Sockets) in which:
-- A single Server and Client exchange information, one after the other.
This is the same example as examples.example1_one_client
except structured in a more OO way. In particular, this structure has 3 classes:
-- Main: for starting the program.
-- Server: for initiating and running the Server.
-- Client: for initiating and running the Client.
Run this program on one computer choosing "Server"
and on another computer choosing "Client".
Or, run both on the same computer; choose "localhost" as the Server HostName.
NOTE:
1. The Server should be started before the Client starts.
2. Before running this program, you may need to tell your Firewall not to
block the port that this program uses (4444, chosen arbitrarily). In Windows, do so by:
Control Panel ~ Windows Firewall ~ Exceptions tab ~ Add Port
and enter the port number (4444) with any name you like.
See examples.example1_one_client
for:
-- Exactly what information the Server and Client exchange in this demo.
-- The 7 Key Statements that are all-you-need-to-know to do networking in Java.
See examples.example3_one_client_OO_library
for this same example
but using the simple networking library in package simpleNetworking
.
- Author:
- David Mutchler, based on the Java Tutorials on networking. May, 2009.
Constructor Summary |
Main()
|
Method Summary |
static void |
main(String[] commandLineArguments)
Asks the user whether she wishes to be the Server or Client,
and constructs whichever she requests. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Main
public Main()
main
public static void main(String[] commandLineArguments)
- Asks the user whether she wishes to be the Server or Client,
and constructs whichever she requests.
- Parameters:
commandLineArguments
- Ignored here