C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




what is server.Flush method and diff b/w


Posted Date: 26 Jul 2008      Total Responses: 1

Posted By: syam kumar       Member Level: Silver     Points: 1


what is server.Flush method and diff b/w server.flush and response.execute



Responses

Author: Vidhya    26 Jul 2008Member Level: GoldRating:     Points: 1
Logging server and Logging client
Write myLoggingServer and myLoggingClient, server and client classes that support the following functionality:

public class myLoggingServer {
myLoggingServer(int port, java.io.Writer outStream);
void writeRecord(String record);
String getRecords(long windowSize);
void flush();
}
myLoggingServer opens a socket on localhost at port number port and establishes outStream as the place to which it writes its output. Once established, myLoggingServer loops forever, doing the following:

accepts a connection from a myLoggingClient on port,

reads a command name ("writeRecord" + "\n", "getRecords" + "\n", or "flush" + "\n") from the socket

reads one record ((ID + "\n" + timestamp + "\n" + event + "\n") or (windowSize)) from the socket,

calls the appropriate method passing the data read from the socket, appropriately converted,

if command was getRecords returns records in original format (ID + "\n" + timestamp + "\n" + event + "\n")

closes the connection.

The field separator for all fields will be the newline (so newlines are not allowed in ID or event strings).
For the purpose of passing a java.util.Date object (either way) between the logging client and server (i.e. as part of a record), the String representation of a Date object should be a value of type long that represents the number of milliseconds since the beginning of Unix time, January 1, 1970, 00:00:00 GMT (see Date.getTime() and the wrapper class Long).
writeRecord stores record on server.
getRecords returns all records that are no older than windowSize milliseconds that have not yet been flushed. Make sure you print out the records in ascending order of their timestamps with one blank line in between each record. The timestamps should be human-readable (use java.util.Date.toString() ).
flush writes all records to outStream and removes them from the server's stored records. Make sure you print out the records in ascending order of their timestamps with one blank line in between each record. The timestamps should be printed using the long format, as for passing them between the client and server.
The public static main() method for your server should get the port number to listen on from the command line (e.g., start the server with java -Dport=portnum myLoggingServer). The port number can be extracted in your server with the Integer.getInteger() method. For testing purposes, so everyone uses different ports, test your server using port x33yy, where x is your section number and yy is your account number.
public class myLoggingClient {
myLoggingClient(InetAddress host, int port);
void writeRecord(String ID, String timestamp, String event);
void viewRecords(long windowSize);
void flush();
}
myLoggingClient stores information needed to connect to the myLoggingServer instance (i.e. host host at port port).
writeRecord() sends its parameters to the myLoggingServer instance previously associated with this myLoggingClient instance, with each parameter string followed by a newline ("\n").
viewRecords() creates a new window on the host machine and displays all records whose timestamp is no older than windowSize milliseconds. See file TestPane.java for a sample program using Swing that displays text in a scrolling window.
flush() sends a flush command to the server.
The driver for the client should get the host and port number of the server to connect to from the command line. For the client driver we provide, ProducerConsumerTest, start with java -Dhost=hostname -Dport=portnum ProducerConsumerTest). As show in the driver, the hostname can be extracted with the System.getProperty() method.


Post Reply
You must Sign In to post a response.
Next : kindly resolve the below error
Previous : ListBox
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

accuconference

Contact Us    Privacy Policy    Terms Of Use