7 replies
by thechas
Here is a site that has some general Java information.
http://www.fawcette.com/javapro/
Also, Tech Republic's sister site www.builder.com.com has a JAVA section and weekly e-mail.
There are documents available from Sun at www.sun.com
Chas
by swtasim
by charbell
/* SimpleServer.java
* @author Charles Bell
* @version December 15, 2000
* email: charles@quantumhyperspace.com
*/
import java.io.*;
import java.net.*;
import java.util.*;
/** When started allows one client to connect. It listens onport 8189.
* It returns whatever a connected client sends.
* It shuts down when the client sends a Bye line.
*
*/
public class SimpleServer{
/** Instantiates an instance of the SimpleServer class and initilaizes it.
*/
public static void main(String[] args){
SimpleServer simpleserver = new SimpleServer();
simpleserver.init();
}
/** Sets up a ServerSocket and listens on port 8189.
*/
public void init(){
ServerSocket serversocket = null;
Socket socket = null;
try{
//establish a server socket monitoring port 8189
//port 8189 is not used by any services
serversocket = new ServerSocket(8189);
System.out.println("Listening at 127.0.0.1 on port 8189"); //wait indefinitely until a client connects to the socket
socket = serversocket.accept();
//set up communications for sending and receiving lines of text data
//establish a bufferedreaderr from the input stream provided by the socket object
InputStreamReader inputstreamreader = new InputStreamReader(socket.getInputStream());
BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
//establish an printwriter using the output streamof the socket object
//and set auto flush on
PrintWriter printwriter = new PrintWriter(socket.getOutputStream(),true);
//for binary data use
// DataInputStream and DataOutputStream
//for serialized objects use // ObjectInputStream and ObjectOutputStream
String datetimestring = (Calendar.getInstance()).getTime().toString();
printwriter.println("You connected to the Si
by swtasim
by port8080
by swtasim
by swtasim
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending