HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"Building a Chat Applet"
Vol. 3, Issue 3, p. 30

Download files assoicated with this article

	

Listing 1: Unlink command.
  
# read the log file data  
 open(LOG,"$filename");  
 @logcache = <LOG>;  
 chop @logcache;  
 close(IN);  
 unshift(@logcache,$date.' '.$contents{'chatline'});  
# Calculate the number of lines our chat log contains  
 $numberOfChatLines = ($#logcache + 1 );  
# check to see if we have exceeded our maximum log size  
 if ($numberOfChatLines > $maxChat){  
    # Remove the oldest chat line  
    pop(@logcache);  
 }  

Listing 2: Run ( ) method.
  
   chatServer = new URL(app.getDocumentBase(),cgiPath+"chat.cgi");  
   chatServerConnection = chatServer.openConnection();  
   chatServerConnection.setDoOutput(true);  
   chatServerConnection.setUseCaches(false);  
   chatServerConnection.setRequestProperty   
      ("Content-type","application/octet-stream");  
   chatServerConnection.setRequestProperty   
      ("Content-length",""+completeMessage.length());  

   DataOutputStream send = new DataOutputStream(chatServerConnection.getOutputStream());  
   send.writeBytes(completeMessage);  
   send.close();  

Listing 3: Chat.CGI may be found on our Web site at www.sys-con.com/java
  
Download the remaining Source Code Listings
 
      
 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.