Web Hosting Tomcat, Java, JSP, Servlets, J2EE, PHP, MySQL

Cheap web hosting provider
XML Feed

Archive for October, 2006

PrintStream ps; String alias; sClientThread(Socket s, sClientGroup p)

Sunday, October 29th, 2006

PrintStream ps; String alias; sClientThread(Socket s, sClientGroup p) { /* called by parent */ theSock = s; parent = p; } The run( ) Method So far, we haven t done too much. Just make sure you understand what each of the global variables will be used […]

Black Art of Java Game Programming by Joel

Saturday, October 28th, 2006

public void finalize() { try { ps.close(); dis.close(); theSock.close(); } catch(Exception e); theSock = null; } public void setAlias(String str) { alias = str; } public String getAlias() { return alias; } } Input all of this, and compile. It should compile just […]

Black Art of Java Game Programming by Joel

Saturday, October 28th, 2006

while( true ) { try{ sleep(30000); } catch (Exception e); cleanHouse(); } } We re almost done! Only one more class to write. Remember, though, that you cannot compile sClientGroup yet, because it imports sClientThread, which hasn t been written yet! To get around this obstacle, let s write […]

Black Art of Java Game Programming by Joel

Saturday, October 28th, 2006

Black Art of Java Game Programming by Joel Fan Sams, Macmillan Computer Publishing ISBN: 1571690433 Pub Date: 11/01/96 Previous Table of Contents Next Automatic Garbage Collection (Reclaiming Unused Memory) Next we need to talk a little about garbage collection. This is a term you may have heard used […]

Explicit Casting When we access an element in

Saturday, October 28th, 2006

A brief mention of the StringBuffer class is important here. StringBuffers are like Strings, except they are designed to have things added and removed. Whenever you change a String, it is temporarily changed into a StringBuffer, operated on, and then returned to a String. The Java compiler takes care of all this […]

Explicit Casting When we access an element in

Saturday, October 28th, 2006

if(cmd.equals(”logout”)) { sendMessage(T.getAlias()+” has left the room.”, cmd); T.stop(); return ; } /* someone wants to “say” something to the whole room */ if(cmd.equals(”say”)) { sendMessage(T.getAlias()+” says: “+ val, cmd); return ; } /* someone wants to whisper something to a specific person only […]

Explicit Casting When we access an element in

Saturday, October 28th, 2006

Explicit Casting When we access an element in theGroup, you may notice that sClientThread in parentheses immediately precedes it. This is called explicit typecasting and is used to convert Objects of different classes. If you ve programmed in C, you ve probably used this to do such things as convert integers […]

while(servSock != null ) { Socket tempSock; try

Friday, October 27th, 2006

Black Art of Java Game Programming by Joel Fan Sams, Macmillan Computer Publishing ISBN: 1571690433 Pub Date: 11/01/96 Previous Table of Contents Next The sendMessage( ) Methods Next, let s write the two methods that will allow us to send messages to different clients. Both have the same […]

while(servSock != null ) { Socket tempSock; try

Friday, October 27th, 2006

That should be enough to get started with the code. Here s the start of sClientGroup.java, which we won t be able to compile until we write sClientThread: import java.net.*; import java.io.*; import java.util.*; import java.lang.*; import sClientThread; public class sClientGroup extends Thread { Vector theGroup; […]

while(servSock != null ) { Socket tempSock; try

Friday, October 27th, 2006

while(servSock != null ) { Socket tempSock; try { tempSock = servSock.accept(); System.out.println(”Received New Connection.”); group.addClient( tempSock ); } catch (Exception e) { System.out.println(”New Connection Failure. Exiting.”); System.exit(1); } } } public void finalize() { try { servSock.close(); } catch(Exception e); […]

Home | About Us | Compare Plans | Standard Hosting | Business Hosting | Java Tomcat Hosting | Support | FAQ | Order Now!

Powered by Omnicus java hosting services. All rights reserved.
Entries (RSS) and Comments (RSS).