Index: trunk/MagicSoft/Mars/mraw/MRawSocketRead.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawSocketRead.cc	(revision 2487)
+++ trunk/MagicSoft/Mars/mraw/MRawSocketRead.cc	(revision 2490)
@@ -35,5 +35,9 @@
 //
 //  Output Containers:
-//   MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MRawEvtTime
+//   MRawRunHeader
+//   MRawEvtHeader
+//   MRawEvtData
+//   MRawCrateArray
+//   MRawEvtTime
 //
 //////////////////////////////////////////////////////////////////////////////
@@ -58,5 +62,5 @@
 #include "MRawCrateArray.h"
 
-//#include "../mmain/MStatusDisplay.h"
+#include "MStatusDisplay.h"
 
 ClassImp(MRawSocketRead);
@@ -69,10 +73,10 @@
 //
 MRawSocketRead::MRawSocketRead(const char *name, const char *title)
-    : fIn(NULL)
+    : fIn(NULL), fPort(-1)
 {
     fName  = name  ? name  : "MRawSocketRead";
     fTitle = title ? title : "Task to read DAQ binary data from tcp/ip socket";
 
-    fIn = new MReadSocket(7000);
+    fIn = new MReadSocket;
 }
 
@@ -84,4 +88,52 @@
 {
     delete fIn;
+}
+
+// --------------------------------------------------------------------------
+//
+// Open the socket. This blocks until the connection has been established,
+// an error occured opening the connection or the user requested to
+// quit the application.
+//
+Bool_t MRawSocketRead::OpenSocket()
+{
+    if (fDisplay)
+        fDisplay->SetStatusLine2(Form("Waiting for connection on port #%d...", fPort));
+
+    //
+    // Open socket connection
+    //
+    while (1)
+    {
+        //
+        // If port could be opened eveything is ok
+        //
+        if (fIn->Open(fPort))
+            return kTRUE;
+
+        //
+        // If a MStatusDisplay is attached the user might have
+        // requested to quit the application
+        //
+        if (fDisplay)
+            switch (fDisplay->CheckStatus())
+            {
+            case MStatusDisplay::kFileClose:
+            case MStatusDisplay::kFileExit:
+                *fLog << inf << "MRawSocketRead::PreProcess - MStatusDisplay triggered exit." << endl;
+                return kFALSE;
+            default:
+                break;
+            }
+
+        //
+        // If an error occured during opening the socket stop
+        //
+        if (fIn->fail())
+            break;
+    }
+
+    *fLog << err << "ERROR - Cannot open port #" << fPort << endl;
+    return kFALSE;
 }
 
@@ -104,4 +156,7 @@
 Int_t MRawSocketRead::PreProcess(MParList *pList)
 {
+    if (!OpenSocket())
+        return kFALSE;
+
     //
     //  check if all necessary containers exist in the Parameter list.
@@ -269,16 +324,21 @@
 
     fEvtNumber=fRawEvtHeader->GetDAQEvtNumber();
-/*
+
     if (fDisplay)
         fDisplay->SetProgressBarPosition((Float_t)fEvtNumber/fRawRunHeader->GetNumEvents());
- */
+
     return kTRUE;
 }
 
 Int_t MRawSocketRead::PostProcess()
-{   /*
+{
+    //
+    // Close Socket connection
+    //
+    fIn->Close();
+
     if (fDisplay)
         fDisplay->SetProgressBarPosition(1);
-     */
+
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mraw/MRawSocketRead.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawSocketRead.h	(revision 2487)
+++ trunk/MagicSoft/Mars/mraw/MRawSocketRead.h	(revision 2490)
@@ -4,8 +4,4 @@
 #ifndef MARS_MTask
 #include "MTask.h"
-#endif
-
-#ifndef __IOSFWD__
-#include <iosfwd>
 #endif
 
@@ -33,7 +29,11 @@
     UInt_t          fEvtNumber;     //!
 
-    Int_t PreProcess(MParList *pList);
-    Int_t Process();
-    Int_t PostProcess();
+    Int_t           fPort;          // Port on which we wait for the connection
+
+    Bool_t OpenSocket();
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+    Int_t  PostProcess();
 
 public:
@@ -41,4 +41,6 @@
     ~MRawSocketRead();
 
+    void SetPort(int port) { fPort = port; }
+
     ClassDef(MRawSocketRead, 0)	//Task to read DAQ binary data from tcp/ip socket
 };
