wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Networking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Networking" Watch "Networking" New topic
Author

Networking

Tim Adam Cooper
Greenhorn

Joined: Jul 29, 2002
Posts: 17
I am currently learning about Networking and Sockets to prepare for my Sun Java Development exam.
Below is a scenairo about networking:
If a company has five computers all connected via a network as below:
Computer´┐Żs Name Type of Computer
Comp1 Windows NT Server
Comp2 Windows NT Server
Comp3 Windows NT Workstation
Comp4 Windows NT Workstation
Comp5 Windows NT Workstation

Below is a program that uses a ServerSocket class to create a Server:
import java.net.*;
import java.io.*;
public class SimpleServer {
public static void main(String args[]){
ServerSocket s = null;
Socket s1;
String sendString="Hello from the Server";
OutputStream slout;
DataOutputStream dos;
try{
s=new ServerSocket(5432);
System.out.println("Server ready");
}catch(IOException e){}
while(true){
try{
s1=s.accept();
slout=s1.getOutputStream();
dos=new DataOutputStream(slout);
dos.writeUTF(sendString);
dos.close();
slout.close();
s1.close();
}catch(IOException e){}
}
}
}
QUESTION:
The question that I would like to ask is must the Server program above be placed in a Server computer (Comp1 and Comp2) or is it OK to put the Server program in a Workstation (Comp3, Comp4 and Comp5) and the Workstation can acts as a server? So for example, can I put the Server program in Comp3 (Workstation) so that Comp3 can acts as a Server to Comp4 (Workstation) and Comp5 (Workstation) ?
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

You can run your server program anywhere u want, including workstations. What's more, u can even run ur server and client on the same machine.
- Manish
 
GeeCON Prague 2014
 
subject: Networking