* system to start the computation up */
task Startup(StartupObject s {initialstate}) {
- String a = new String("hello\n");
- String b = new String("hello\n");
- System.printString(a);
- System.printString(b);
- System.printInt(b.hashCode());
- System.printString("\n");
- System.printInt(a.hashCode());
-
for(int i=0;i<10;i++) {
Example e=new Example() {needoperation};
e.x=i;
task ProcessRequest(WebServerSocket web{IOPending && WebInitialize}) {
//task ProcessRequest(WebServerSocket web{IOPending}) {
System.printString("W> Inside ProcessRequest... \n");
- web.clientrequest();
- if(web.checktrans()==false)
+ if (web.clientrequest()) {
+ if(web.checktrans()==false)
// Not special transaction , do normal filesending
taskexit(web {WritePending, LogPending,!WebInitialize}); //Sets the WritePending and LogPending flag true
- else
+ else
// Invoke special inventory transaction
taskexit(web {TransPending, LogPending,!WebInitialize});
+ }
}
//Do the WriteIO on server socket and send the requested file to Client
//Filename requested by the client
String filename;
- String[] parsed;
+ String[] parsed;
+ String prefix;
//Constructor
public WebServerSocket(){
}
//Read the client request and extract the filename from it
- public int clientrequest(){
+ public boolean clientrequest(){
byte b1[] = new byte[1024];
- read(b1);//Read client request from web server socket
- String clientreq = new String(b1);
- int index = clientreq.indexOf('/');//Parse the GET client request to find filename
- int end = clientreq.indexOf('H');
- filename = clientreq.subString((index+1), (end-1));
- System.printString("\n");
- return 0;
+ int numbytes=read(b1);//Read client request from web server socket
+ String curr=(new String(b1)).subString(0, numbytes);
+ if (prefix!=null) {
+ StringBuffer sb=new StringBuffer(prefix);
+ sb.append(curr);
+ curr=sb.toString();
+ }
+ prefix=curr;
+ if(prefix.indexOf("\r\n\r\n")>=0) {
+
+ int index = prefix.indexOf('/');//Parse the GET client request to find filename
+ int end = prefix.indexOf('H');
+ filename = prefix.subString((index+1), (end-1));
+ System.printString("\n");
+ return true;
+ }
+ return false;
}
// Parse for the prefix in the client request