Index: /trunk/AddOn/TAcq/README
===================================================================
--- /trunk/AddOn/TAcq/README	(revision 3542)
+++ /trunk/AddOn/TAcq/README	(revision 3542)
@@ -0,0 +1,49 @@
+###########################################################
+   Repertoire TAcq  
+   Programmes de test pour acquisition/traitement BAORadio
+   + classes socket developpes en 2005 pour etre ajoute a
+   SOPHYA 
+   Module CVSSophya/AddOn/TAcq
+###########################################################
+
+1/ programmes de test debit I/O disque
+  traidio.cc (main prog fits/PPF/binary file) 
+  et traidf.cc/traidp.cc (pour runcxx)
+
+2/ classes I/O fits simplifiee 
+  - minifits.h  minifits.cc 
+  - programmes de test tstminifits.cc tstrdfits.cc
+
+3/ Utilitaires pour Acq Nancay  
+  -  Programme mfits2spec.cc de calcul de spectre moyennes a partir 
+    fichiers Acq : mfits2spec file1.fits [file2.fits ...] 
+  - dispspectre.pic
+
+4/ Ensemble de classe + main programme Acq multi-thread
+  - tmtacq.cc : le main program
+  - racqumem.h racqumem.cc  : gestionnaire de zones memoires echanges
+    entres threads
+  - racqurw.h  racqurw.cc : les deux classes de  "threads" de DMA-PCI-E et I/O disque
+  - racquproc.h racquproc.cc : la classe thread de traitement des donnees
+
+        ================ Remote ====================
+
+5/ Ensemble de classes + programme test developpes en 2005, pour I/O PPF sur 
+   stream IP - provenaant du repertoire Remote
+  - swrapsock.h swrapsock.cc : Classes Socker ServerSocket ClientSocket 
+    d'enrobage de creation et de manipulation des sockets unix
+  - sockrawstream.h sockrawstream.cc : classes RawInOutSocketStream 
+   permettant de construire des streams PPF sur flots IP
+  - burawstream.h burawstream.cc : classe RawInOutBuffStream - 
+  soit a virer ou a transformer en une classe pour I/O PPF sur fichier 
+  distant a l'aide d'un serveur specifique
+  - tsok.cc : programme de test , cote client ou serveur :
+
+    Usage : tsok S/C [servername=localhost] [OPEMsg=Hello] [NLoop,SizeX,SizeY] 
+    Ex: tsok S   or  tsok C serverName or 
+        tsok C serverName PPFSOCKET  5  1000,1000 
+   S : run tsok as server side 
+   C : run tsok as client side 
+   OPEMsg : Operation select on client side (=XXX , PPFSOCKET , STOP)   
+   serverName : Name or IP adress of the machine where tsok S is running 
+   NLoop,SizeX,SizeY: Number of transfers, 2D array size for OPEMsg=PPFSOCKET 
Index: /trunk/AddOn/TAcq/burawstream.cc
===================================================================
--- /trunk/AddOn/TAcq/burawstream.cc	(revision 3542)
+++ /trunk/AddOn/TAcq/burawstream.cc	(revision 3542)
@@ -0,0 +1,188 @@
+#include "burawstream.h"
+#include "sopnamsp.h"
+#include "pexceptions.h"
+
+/*!
+   \class SOPHYA::RawInOutBuffStream
+   \ingroup SysTools
+   This class implements the interface defined by RawInOutStream 
+   over a socket (read and write operations)
+*/
+
+#define SWRB_SIZE 1024 /* Taille des buffers I/O */
+
+/* --Methode-- */
+RawInOutBuffStream::RawInOutBuffStream(const char * nom)
+  : RawInOutStream() 
+{
+  _fip = fopen(nom, "w+b");
+  _rdbuff.buff = new char[SWRB_SIZE];
+  _rdbuff.sz = SWRB_SIZE;
+  _rdbuff.cpos = SWRB_SIZE;
+
+  _wrbuff.buff = new char[SWRB_SIZE];
+  _wrbuff.sz = SWRB_SIZE;
+  _wrbuff.cpos = 0;
+  _totnwr = 0;
+  _totnrd = 0;
+}
+
+/* --Methode-- */
+RawInOutBuffStream::~RawInOutBuffStream()
+{
+  cout << " ---- DESTRUCTEUR ---- ~RawInOutBuffStream() " << endl;
+  if (_wrbuff.cpos > 0) {
+    for (size_t k= _wrbuff.cpos; k<_wrbuff.sz; k++)
+      _wrbuff.buff[k] = '\0';
+    _wrbuff.cpos = _wrbuff.sz;
+    SendBuffer();
+  }
+  fclose(_fip);
+  delete [] _rdbuff.buff;
+  delete [] _wrbuff.buff;
+}
+
+/* --Methode-- */
+size_t RawInOutBuffStream::CopyToSendBuffer(const char* s, size_t n)
+{
+
+  size_t len = _wrbuff.sz-_wrbuff.cpos;
+  if (len > n) len = n;
+  if ( (_wrbuff.cpos == 0) && (len == _wrbuff.sz) ) {
+    cout << "RawInOutBuffStream::CopyToSend/DBG-1 - n=" 
+	 << n << " len=" << len << endl;
+    Send(s, len);
+  }
+  else {
+    cout << "RawInOutBuffStream::CopyToSend/DBG-2 - n=" 
+	 << n << " len=" << len << " cpos=" << _wrbuff.cpos << endl;
+    memcpy(_wrbuff.buff+_wrbuff.cpos, s, len);
+    cout << " memcpy OK - cpos= " << _wrbuff.cpos << endl;
+    _wrbuff.cpos += len;
+    if (_wrbuff.cpos == _wrbuff.sz)  SendBuffer();
+  }
+  return len;
+}
+
+/* --Methode-- */
+size_t RawInOutBuffStream::CopyFromRecvBuffer(char* s, size_t n)
+{
+  if ( (_rdbuff.cpos == _rdbuff.sz) && ( n >= _rdbuff.sz)) {
+    size_t len = _rdbuff.sz;
+    cout << "RawInOutBuffStream::CopyFromRecv/DBG-1 - n=" << n 
+	 << " len=" << len << endl;
+    Receive(s, len);
+    return len;
+  }
+  else {
+    cout << "RawInOutBuffStream::CopyFromRecv/DBG-2 - n=" << n << endl;
+    if (_rdbuff.cpos == _rdbuff.sz)  ReceiveBuffer();
+    size_t len = _rdbuff.sz-_rdbuff.cpos;
+    if (len > n) len = n;
+    memcpy(s, _rdbuff.buff+_rdbuff.cpos, len);
+    _rdbuff.cpos += len;
+    return len;
+  }
+}
+
+/* --Methode-- */
+void RawInOutBuffStream::SendBuffer()
+{
+  cout << "RawInOutBuffStream::SendBuffer/DBG - cpos=" 
+       <<  _wrbuff.cpos << " sz=" << _wrbuff.sz << endl;
+  //  if (_wrbuff.cpos != _wrbuff.sz)  return;
+  Send(_wrbuff.buff, _wrbuff.sz);
+  _wrbuff.cpos = 0;
+}
+
+/* --Methode-- */
+void RawInOutBuffStream::ReceiveBuffer()
+{
+  //  if (_rdbuff.cpos != _rdbuff.sz)  return;
+  cout << "RawInOutBuffStream::ReceiveBuffer/DBG - cpos=" 
+       <<  _rdbuff.cpos << " sz=" << _rdbuff.sz << endl;
+  Receive(_rdbuff.buff, _rdbuff.sz);
+  _rdbuff.cpos = 0;
+  
+}
+
+/* --Methode-- */
+size_t RawInOutBuffStream::Send(const char* s, size_t n)
+{
+  size_t  nst = 0;
+  while (nst < n) {
+    size_t ns = fwrite(s, 1, n, _fip);;
+    if (ns < 1)  break;
+    nst += ns;
+  }
+  if ( nst < n) 
+    throw IOExc("RawInOutBuffStream::Send()/write() Error nwrite < n");
+  return nst;
+}
+
+/* --Methode-- */
+size_t RawInOutBuffStream::Receive(char* s, size_t n)
+{
+  size_t  nst = 0;
+  int ntry = 0;
+  while (nst < n) {
+    size_t ns = fread(s, 1, n, _fip);
+    ntry++;
+    if (ns < 1)  break;
+    nst += ns;
+  }
+  if ( nst < n) {
+    cout << "  RawInOutBuffStream::Receive() / Pb ! ntry=" << ntry
+	 << " nst=" << nst << " n=" << n << endl;
+    throw IOExc("RawInOutBuffStream::Receive/read() Error nread < n");
+  }
+  return nst;
+}
+
+/* --Methode-- */
+int_8 RawInOutBuffStream::tellg()
+{
+  return _totnrd;
+}
+
+/* --Methode-- */
+RawInOutStream& RawInOutBuffStream::read(char* s, uint_8 n)
+{
+  cout << "RawInOutBuffStream::read()/DBG - n=" << n << endl;
+  size_t  nst = 0;
+  while (nst < n) {
+    size_t ns = CopyFromRecvBuffer(s+nst, n-nst);
+    if (ns < 1)  break;
+    nst += ns;
+  }
+  if ( nst < n) 
+    throw IOExc("RawInOutBuffStream::read() Error nread < n");
+  _totnrd += n;
+  return *this;
+}
+
+/* --Methode-- */
+int_8 RawInOutBuffStream::tellp()
+{
+  return _totnwr;
+}
+
+/* --Methode-- */
+RawInOutStream& RawInOutBuffStream::write(const char* s, uint_8 n)
+{
+  cout << "RawInOutBuffStream::write()/DBG - n=" << n << endl;
+  size_t  nst = 0;
+  while (nst < n) {
+    size_t ns = CopyToSendBuffer(s+nst, n-nst);
+    if (ns < 1)  break;
+    nst += ns;
+  }
+  cout << "RawInOutBuffStream::write()/DBG ---> nst=" << nst << endl;
+  
+  if ( nst < n) 
+    throw IOExc("RawInOutBuffStream::write() Error nwrite < n");
+  _totnwr += n;
+  return *this;
+}
+
+
Index: /trunk/AddOn/TAcq/burawstream.h
===================================================================
--- /trunk/AddOn/TAcq/burawstream.h	(revision 3542)
+++ /trunk/AddOn/TAcq/burawstream.h	(revision 3542)
@@ -0,0 +1,48 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+#ifndef BUFFRAWSTREAM_H_SEEN
+#define BUFFRAWSTREAM_H_SEEN
+
+// Classe de flot brut sur socket - pour utilisation par les streams PPersist
+// R. Ansari      LAL IN2P3/CNRS  11/2005
+
+#include "machdefs.h"
+#include "rawstream.h"
+
+
+namespace SOPHYA {
+
+// Input flow over a socket
+class RawInOutBuffStream : public RawInOutStream {
+public:
+                      RawInOutBuffStream(const char * nom);
+  virtual             ~RawInOutBuffStream();
+
+  // Lecture 
+  virtual int_8       tellg();
+  virtual RawInOutStream& read(char* s, uint_8 n); 
+  // Ecriture 
+  virtual int_8       tellp();
+  virtual RawInOutStream& write(const char* s, uint_8 n);
+
+protected:
+  size_t CopyToSendBuffer(const char* s, size_t n);
+  size_t CopyFromRecvBuffer(char* s, size_t n);
+  void SendBuffer();
+  void ReceiveBuffer();
+
+  size_t Send(const char* s, size_t n);
+  size_t Receive(char* s, size_t n);
+
+  FILE * _fip;
+  struct SRWBuff { char* buff; size_t sz, cpos; };
+  SRWBuff _rdbuff;
+  SRWBuff _wrbuff;
+  size_t _totnwr;
+  size_t _totnrd;
+};
+
+
+} // namespace SOPHYA
+
+#endif
Index: /trunk/AddOn/TAcq/makefile
===================================================================
--- /trunk/AddOn/TAcq/makefile	(revision 3541)
+++ /trunk/AddOn/TAcq/makefile	(revision 3542)
@@ -1,8 +1,8 @@
 include $(SOPHYABASE)/include/sophyamake.inc
 
-all : traidio  tmtfft tstminifits tpciew tbrpaq tmtacq tstrdfits mfits2spec 
+all : traidio  tmtfft tstminifits tpciew tbrpaq tmtacq tstrdfits mfits2spec tsok
 
 clean :
-	rm *.o traidio tmtfft tstminifits tpciew tbrpaq tmtacq tstrdfits mfits2spec *.ppf *.fits
+	rm *.o traidio tmtfft tstminifits tpciew tbrpaq tmtacq tstrdfits mfits2spec tsok *.ppf *.fits 
 
 ########################################################
@@ -79,2 +79,20 @@
 	$(CXXCOMPILE) -o tmtfft.o tmtfft.cc
 
+
+##   -------------- Ex.repertoire Remote ---------
+
+tsok : tsok.o  swrapsock.o sockrawstream.o burawstream.o 
+	$(CXXLINK) -o tsok tsok.o  swrapsock.o sockrawstream.o \
+	burawstream.o $(SOPHYASLBLIST)
+
+tsok.o : tsok.cc swrapsock.h sockrawstream.h  
+	$(CXXCOMPILE) tsok.cc
+
+swrapsock.o : swrapsock.cc swrapsock.h 
+	$(CXXCOMPILE) swrapsock.cc
+
+sockrawstream.o : sockrawstream.cc sockrawstream.h 
+	$(CXXCOMPILE) sockrawstream.cc
+
+burawstream.o : burawstream.cc burawstream.h 
+	$(CXXCOMPILE) burawstream.cc
Index: /trunk/AddOn/TAcq/sockrawstream.cc
===================================================================
--- /trunk/AddOn/TAcq/sockrawstream.cc	(revision 3542)
+++ /trunk/AddOn/TAcq/sockrawstream.cc	(revision 3542)
@@ -0,0 +1,185 @@
+#include "sockrawstream.h"
+#include "sopnamsp.h"
+#include "pexceptions.h"
+
+/*!
+   \class SOPHYA::RawInOutSocketStream
+   \ingroup SysTools
+   This class implements the interface defined by RawInOutStream 
+   over a socket (read and write operations).
+   It is mainly intended to be used by PPF In/Out streams.
+*/
+
+
+/* --Methode-- */
+RawInOutSocketStream::RawInOutSocketStream(Socket &skt, size_t rwb_size)
+  : RawInOutStream() , _skt(skt)
+{
+  if (rwb_size < 1) rwb_size = 256;
+  _rdbuff.buff = new char[rwb_size];
+  _rdbuff.sz = rwb_size;
+  _rdbuff.cpos = rwb_size;
+
+  _wrbuff.buff = new char[rwb_size];
+  _wrbuff.sz = rwb_size;
+  _wrbuff.cpos = 0;
+  
+}
+
+/* --Methode-- */
+RawInOutSocketStream::~RawInOutSocketStream()
+{
+  //DBG  cout << " ---- DESTRUCTEUR ---- ~RawInOutSocketStream() " << endl;
+  if (_wrbuff.cpos > 0) {
+    for (size_t k= _wrbuff.cpos; k<_wrbuff.sz; k++)
+      _wrbuff.buff[k] = '\0';
+    _wrbuff.cpos = _wrbuff.sz;
+    SendBuffer();
+  }
+  delete [] _rdbuff.buff;
+  delete [] _wrbuff.buff;
+}
+
+/* --Methode-- */
+size_t RawInOutSocketStream::CopyToSendBuffer(const char* s, size_t n)
+{
+
+  size_t len = _wrbuff.sz-_wrbuff.cpos;
+  if (len > n) len = n;
+  if ( (_wrbuff.cpos == 0) && (len == _wrbuff.sz) ) {
+ //DBG   cout << "RawInOutSocketStream::CopyToSend/DBG-1 - n=" 
+//DBG	 << n << " len=" << len << endl;
+    Send(s, len);
+  }
+  else {
+ //DBG   cout << "RawInOutSocketStream::CopyToSend/DBG-2 - n=" 
+//DBG	 << n << " len=" << len << " cpos=" << _wrbuff.cpos << endl;
+    memcpy(_wrbuff.buff+_wrbuff.cpos, s, len);
+    //DBG    cout << " memcpy OK - cpos= " << _wrbuff.cpos << endl;
+    _wrbuff.cpos += len;
+    if (_wrbuff.cpos == _wrbuff.sz)  SendBuffer();
+  }
+  return len;
+}
+
+/* --Methode-- */
+size_t RawInOutSocketStream::CopyFromRecvBuffer(char* s, size_t n)
+{
+  if ( (_rdbuff.cpos == _rdbuff.sz) && ( n >= _rdbuff.sz)) {
+    size_t len = _rdbuff.sz;
+  //DBG  cout << "RawInOutSocketStream::CopyFromRecv/DBG-1 - n=" << n 
+//DBG	 << " len=" << len << endl;
+    Receive(s, len);
+    return len;
+  }
+  else {
+//DBG    cout << "RawInOutSocketStream::CopyFromRecv/DBG-2 - n=" << n << endl;
+    if (_rdbuff.cpos == _rdbuff.sz)  ReceiveBuffer();
+    size_t len = _rdbuff.sz-_rdbuff.cpos;
+    if (len > n) len = n;
+    memcpy(s, _rdbuff.buff+_rdbuff.cpos, len);
+    _rdbuff.cpos += len;
+    return len;
+  }
+}
+
+/* --Methode-- */
+void RawInOutSocketStream::SendBuffer()
+{
+//DBG  cout << "RawInOutSocketStream::SendBuffer/DBG - cpos=" 
+ //DBG      <<  _wrbuff.cpos << " sz=" << _wrbuff.sz << endl;
+  //  if (_wrbuff.cpos != _wrbuff.sz)  return;
+  Send(_wrbuff.buff, _wrbuff.sz);
+  _wrbuff.cpos = 0;
+}
+
+/* --Methode-- */
+void RawInOutSocketStream::ReceiveBuffer()
+{
+  //  if (_rdbuff.cpos != _rdbuff.sz)  return;
+ //DBG cout << "RawInOutSocketStream::ReceiveBuffer/DBG - cpos=" 
+ //DBG      <<  _rdbuff.cpos << " sz=" << _rdbuff.sz << endl;
+  Receive(_rdbuff.buff, _rdbuff.sz);
+  _rdbuff.cpos = 0;
+  
+}
+
+/* --Methode-- */
+size_t RawInOutSocketStream::Send(const char* s, size_t n)
+{
+  size_t  nst = 0;
+  while (nst < n) {
+    size_t ns = _skt.Send(s+nst, n-nst);
+    if (ns < 1)  break;
+    nst += ns;
+  }
+  if ( nst < n) 
+    throw IOExc("RawInOutSocketStream::Send()/write() Error nwrite < n");
+  return nst;
+}
+
+/* --Methode-- */
+size_t RawInOutSocketStream::Receive(char* s, size_t n)
+{
+  size_t  nst = 0;
+  int ntry = 0;
+  while (nst < n) {
+    size_t ns = _skt.Receive(s+nst, n-nst);
+    ntry++;
+    if (ns < 1)  break;
+    nst += ns;
+  }
+  if ( nst < n) {
+    cout << "  RawInOutSocketStream::Receive() / Pb ! ntry=" << ntry
+	 << " nst=" << nst << " n=" << n << endl;
+    throw IOExc("RawInOutSocketStream::Receive/read() Error nread < n");
+  }
+  return nst;
+}
+
+int_8 RawInOutSocketStream::tellg()
+{
+  return _totnrd;
+}
+
+/* --Methode-- */
+RawInOutStream& RawInOutSocketStream::read(char* s, uint_8 n)
+{
+//DBG  cout << "RawInOutSocketStream::read()/DBG - n=" << n << endl;
+  size_t  nst = 0;
+  while (nst < n) {
+    size_t ns = CopyFromRecvBuffer(s+nst, n-nst);
+    if (ns < 1)  break;
+    nst += ns;
+  }
+  if ( nst < n) 
+    throw IOExc("RawInOutSocketStream::read() Error nread < n");
+  _totnrd += n;
+  return *this;
+}
+
+/* --Methode-- */
+int_8 RawInOutSocketStream::tellp()
+{
+  return _totnwr;
+}
+
+/* --Methode-- */
+RawInOutStream& RawInOutSocketStream::write(const char* s, uint_8 n)
+{
+//DBG  cout << "RawInOutSocketStream::write()/DBG - n=" << n << endl;
+  size_t  nst = 0;
+  while (nst < n) {
+    size_t ns = CopyToSendBuffer(s+nst, n-nst);
+    if (ns < 1)  break;
+    nst += ns;
+  }
+ //DBG cout << "RawInOutSocketStream::write()/DBG ---> nst=" << nst << endl;
+  
+  if ( nst < n) 
+    throw IOExc("RawInOutSocketStream::write() Error nwrite < n");
+  _totnwr += n;
+  return *this;
+}
+
+
Index: /trunk/AddOn/TAcq/sockrawstream.h
===================================================================
--- /trunk/AddOn/TAcq/sockrawstream.h	(revision 3542)
+++ /trunk/AddOn/TAcq/sockrawstream.h	(revision 3542)
@@ -0,0 +1,49 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+#ifndef SOCKRAWSTREAM_H_SEEN
+#define SOCKRAWSTREAM_H_SEEN
+
+// Classe de flot brut sur socket - pour utilisation par les streams PPersist
+// R. Ansari      LAL IN2P3/CNRS  11/2005
+
+#include "machdefs.h"
+#include "rawstream.h"
+#include "swrapsock.h"
+
+
+namespace SOPHYA {
+
+// Input flow over a socket
+class RawInOutSocketStream : public RawInOutStream {
+public:
+                      RawInOutSocketStream(Socket& skt, size_t rwb_size=1024);
+  virtual             ~RawInOutSocketStream();
+
+  // Lecture 
+  virtual int_8       tellg();
+  virtual RawInOutStream& read(char* s, uint_8 n); 
+  // Ecriture 
+  virtual int_8       tellp();
+  virtual RawInOutStream& write(const char* s, uint_8 n);
+
+protected:
+  size_t CopyToSendBuffer(const char* s, size_t n);
+  size_t CopyFromRecvBuffer(char* s, size_t n);
+  void SendBuffer();
+  void ReceiveBuffer();
+
+  size_t Send(const char* s, size_t n);
+  size_t Receive(char* s, size_t n);
+
+  Socket & _skt;
+  struct SRWBuff { char* buff; size_t sz, cpos; };
+  SRWBuff _rdbuff;
+  SRWBuff _wrbuff;
+  size_t _totnwr;
+  size_t _totnrd;
+};
+
+
+} // namespace SOPHYA
+
+#endif
Index: /trunk/AddOn/TAcq/swrapsock.cc
===================================================================
--- /trunk/AddOn/TAcq/swrapsock.cc	(revision 3542)
+++ /trunk/AddOn/TAcq/swrapsock.cc	(revision 3542)
@@ -0,0 +1,241 @@
+#ifdef OSF1 
+#define _XOPEN_SOURCE 500
+#endif
+#include "swrapsock.h"
+#include "sopnamsp.h"
+
+#include <time.h>
+
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <sys/errno.h>
+#include <unistd.h>
+
+#include <iostream>
+
+/*! 
+  \class SOPHYA::Socket
+  \ingroup SysTools
+  \brief Base class for server and client sockets.
+  
+  The class Socket is not intended for direct use. Only the derived classes 
+  ServerSocket and ClientSocket should be used.
+*/
+
+/* --Methode-- */
+Socket::Socket(int s)
+{
+  skt = s;
+  tstart = tlast = (long)time(NULL);
+  totsnd = totrcv = 0;
+  dts = dtr = 0;
+  nbbs = nbbr = 0;
+  lstnbb = 0; lstdt = 0;
+  errcnt = 0;
+}
+
+/* --Methode-- */
+/*  ---  A faire plus tard ...
+Socket::Socket(Socket const & a)
+{
+  skt = a.skt;
+  tstart = a.tstart; tlast = a.tlast; 
+  totsnd = a.totsnd; totrcv = a.totrcv;
+  dts = a.dts; dtr = a.dtr;
+  nbbs = a.nbbs; nbbr = a.nbbr;
+  lstnbb = a.lstnbb;   lstdt = a.lstdt;
+  errcnt = a.errcnt;
+}
+*/
+
+/* --Methode-- */
+Socket::~Socket()
+{
+  Close();
+}
+
+/* --Methode-- */
+size_t Socket::Send(const char * buff, size_t len, int flag)
+{
+  ssize_t rc;
+  rc = send(skt, buff, len, flag);
+  if (rc > 0)  { 
+    // tlast = (long)time(NULL);
+    totsnd += rc; 
+    return(rc);
+  }
+  else return 0;
+}
+
+/* --Methode-- */
+size_t Socket::Receive(char * buff, size_t len, int flag)
+{
+  ssize_t rc;
+  //  int fromlen = 0;
+  bool encore = true;
+  while (encore) {
+    rc = recv(skt, buff, len, flag);
+    //    rc = recvfrom(skt, buff, len, flag, NULL, &fromlen);
+    if ((rc < 1) && (errno == EAGAIN))  usleep(20000);
+    else encore = false;
+  }
+  if (rc > 0)  { 
+    // tlast = (long)time(NULL);
+    totrcv += rc; 
+    return(rc);
+  }
+  else return 0;
+}
+
+// extern int errno;
+
+/* --Methode-- */
+int Socket::Close()
+{
+  if (skt<0) return 0;
+  int rc=-1;
+  rc = shutdown(skt, SHUT_RDWR);
+  if(rc < 0) 
+    cout << "Socket::Close() Erreur: Pb shutdown() ErrNo="
+	 << errno << endl;
+
+  rc = close(skt);
+  if(rc < 0) 
+    cout << "Socket::Close() Erreur: Pb close() ErrNo="
+	 << errno << endl;
+  skt = -1;
+  return(0);
+}
+
+
+/*! 
+  \class SOPHYA::ServerSocket
+  \ingroup SysTools
+  \brief Socket wrapper class for the server side
+*/
+
+/* --Methode-- */
+ServerSocket::ServerSocket(int port, int nconmax)
+  : Socket() 
+{
+  int s,rc;
+  s = socket(AF_INET, SOCK_STREAM, 0);
+  if (s < 0) { 
+    cout << "ServerSocket() Pb socket() ErrNo=" <<  errno << endl;  
+    throw SocketException("ServerSocket() Pb socket()");
+    }
+  skt = s;
+  if (nconmax <= 1)  nconmax = 1;
+  NConMax = nconmax;
+  nclitot = 0;
+
+  portid = port; 
+  ipskt.sin_family = AF_INET;
+  ipskt.sin_port = htons(port);
+  ipskt.sin_addr.s_addr = INADDR_ANY;
+  /* Je fais un cast explicit de sockaddr_in * (Internet) en sockaddr *   */
+  rc = bind(skt, (struct sockaddr *)(&ipskt), sizeof(ipskt));
+  if (rc < 0) {
+    Close();
+    cout << "ServerSocket() Pb bind() ErrNo=" <<  errno << endl;  
+    throw SocketException("ServerSocket() Pb bind()");
+  }
+}
+
+/* --Methode-- */
+Socket ServerSocket::WaitClientConnection()
+{
+  int rc,s,len;
+  struct sockaddr_in cli;
+
+  rc = listen(skt, NConMax);
+  if (rc < 0) {
+    cout << "ServerSocket::WaitClientConnection() Pb listen() ErrNo="
+	 << errno << endl;  
+    throw SocketException("ServerSocket::WaitClientConnection() Pb listen()");
+  }
+  
+  /* Je fais un cast explicit de sockaddr_in * (Internet) en sockaddr *   */
+  socklen_t sl = sizeof(cli);
+  s = accept(skt, (struct sockaddr *)(&cli), &sl);
+  if(s < 0) {
+    cout << "ServerSocket::WaitClientConnection() Pb accpet() ErrNo="
+	 << errno << endl;  
+    throw SocketException("ServerSocket::WaitClientConnection() Pb accept()");
+  }
+  nclitot++;
+
+  return Socket(s); 
+}
+
+
+/*! 
+  \class SOPHYA::ClientSocket
+  \ingroup SysTools
+  \brief Socket wrapper class for the client side
+*/
+
+/* --Methode-- */
+ClientSocket::ClientSocket(string const& srvname, int port)
+  : Socket()
+{
+  InitConnection(srvname.c_str(), port);
+}
+
+/* --Methode-- */
+ClientSocket::ClientSocket(const char* srvname, int port)
+  : Socket()
+{
+  InitConnection(srvname, port);
+}
+
+/* --Methode-- */
+void ClientSocket::InitConnection(const char* name, int port)
+{
+  struct hostent *server;
+  int s,rc;
+#if defined(Linux)  || defined(linux)
+  typedef unsigned long in_addr_t;
+#endif
+  in_addr_t inad;
+  
+  server = NULL;
+  /*  Try to find out if this is a known machine name  */
+  server = gethostbyname(name);   
+  if(!server) {   
+    /*  Try it as an internet address  a.b.c.d  */  
+    /*    inad = inet_addr(name);
+	  if(inad == INADDR_NONE) {
+	  cout << "ClientSocket() Host identification failed inet_addr(" 
+	  << name << ")" << endl;
+	  throw SocketException("ClientSocket() Host identification failed ");
+	  }
+    */
+    server = gethostbyaddr(name, strlen(name), AF_INET);
+  }
+  if(!server) {
+    cout << "ClientSocket() Host identification failed (2) for" 
+	 << name << endl;
+    throw SocketException("ClientSocket() Host identification failed (2)");
+  }
+
+  ipskt.sin_family = AF_INET;
+  ipskt.sin_port = htons(port);
+  memcpy(&(ipskt.sin_addr), server->h_addr, server->h_length);
+  s = socket(AF_INET, SOCK_STREAM, 0);
+  if (s < 0) {
+    cout << "ClientSocket() Erreur: Pb socket() ErrNo=" << errno << endl;  
+    throw SocketException("ClientSocket() Erreur: Pb socket()");
+  }
+
+
+  skt = s;
+  portid = port; 
+/* Je fais un cast explicit de sockaddr_in * (Internet) en sockaddr *   */
+  rc = connect(skt, (struct sockaddr *)(&ipskt), sizeof(struct sockaddr_in));
+  if (rc < 0) {
+    cout << "ClientSocket() Erreur: Pb connect() ErrNo=" << errno << endl; 
+    Close();
+    throw SocketException("ClientSocket() Erreur: Pb connect()");
+  }
+}
Index: /trunk/AddOn/TAcq/swrapsock.h
===================================================================
--- /trunk/AddOn/TAcq/swrapsock.h	(revision 3542)
+++ /trunk/AddOn/TAcq/swrapsock.h	(revision 3542)
@@ -0,0 +1,100 @@
+#ifndef SWRAPSOCK_H
+#define SWRAPSOCK_H
+
+#include "machdefs.h"
+#include "pexceptions.h"
+
+#include <unistd.h>
+#include <iostream>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+
+namespace SOPHYA {
+
+/*! 
+  \class SocketException
+  \ingroup SysTools
+  \brief Exception class used by IP socket wrapper classes in SysTools module
+*/
+
+class SocketException : public PException {
+  public:
+  explicit SocketException(const char * m) : PException(m) {}
+  explicit SocketException(const string& m) : PException(m) {}
+};
+
+
+//  --------------------------  
+// Classe de base pour enrober l'initialisation et l'utilisation 
+// des sockets pour les connections IP.
+//  --------------------------   
+
+class Socket {
+public:
+  Socket(int s=-1);
+  //  Socket(Socket const & a);
+  ~Socket();
+
+  size_t Send(const char * buff, size_t len, int flag=0);
+  size_t Receive(char * buff, size_t len, int flag=0);
+  int Close();
+  inline int SetPrtLevel(int lev=0) 
+    { if (lev > 0) prtlev = lev; return prtlev; }
+
+protected:
+  
+  int skt;
+  long tstart;    /*  Temps de demarrage en sec  */
+  long tlast;     /*  Temps de derniere acces en sec */
+  long totrcv;    /*  Nb total d'octets recus  */
+  long totsnd;    /*  Nb total d'octets envoyes */
+  long dts;       /*  Dt en ms send (File or Data) */
+  long nbbs;      /*  Nb Octets send (File or Data) */
+  long dtr;       /*  Dt en ms recv (File or Data) */
+  long nbbr;      /*  Nb Octets recv (File or Data) */
+  long lstdt;     /*  Dt en ms last send or receive */
+  long lstnbb;    /*  Nb bytes last send or receive */
+  long errcnt;    /*  Total error count */
+  int prtlev;
+};
+
+
+//  --------------------------  
+//  Classe ServerSocket - A instancier cote serveur
+//  --------------------------   
+
+class ServerSocket : public Socket
+{
+public :
+  ServerSocket(int port, int nconmax);
+  Socket WaitClientConnection();
+
+protected:
+  int portid;
+  struct sockaddr_in  ipskt;
+  int NConMax;
+  int nclitot;  
+};
+
+//  --------------------------  
+//  Classe ClientSocket - A instancier cote client
+//  --------------------------   
+
+class ClientSocket : public Socket
+{
+public :
+  ClientSocket(string const& srvname, int port);
+  ClientSocket(const char* srvname, int port);
+protected:
+  void InitConnection(const char* srvname, int port);
+  int portid;
+  struct sockaddr_in  ipskt;
+
+};
+
+} // Fin du namespace
+
+#endif
Index: /trunk/AddOn/TAcq/tsok.cc
===================================================================
--- /trunk/AddOn/TAcq/tsok.cc	(revision 3542)
+++ /trunk/AddOn/TAcq/tsok.cc	(revision 3542)
@@ -0,0 +1,240 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <iostream>
+
+#include "sopnamsp.h"
+#include "array.h"
+#include "tarrinit.h"
+#include "timing.h"
+#include "ctimer.h"
+#include "swrapsock.h"
+#include "sockrawstream.h"
+#include "burawstream.h"
+
+// Numero de port pour la connection IP
+#define PORTID 1962
+
+void burawtst(); 
+void serverside(); 
+void clientside(string& servname, string& msg, string& args);
+
+int main(int narg, char *arg[])
+{
+  cout << " ---- Programme tsok.cc - Test classes Socket --- " << endl;
+  if (narg < 2) {
+    cout << " Erreur Argument / tsok.cc : Socket class tests \n" 
+         << "    Usage : tsok S/C [servername=localhost] [OPEMsg=Hello] [NLoop,SizeX,SizeY] \n" 
+         << "    Ex: tsok S   or  tsok C serverName or \n" 
+         << "        tsok C serverName PPFSOCKET  5  1000,1000 \n" 
+         << "   S : run tsok as server side \n" 
+         << "   C : run tsok as client side \n"
+         << "   OPEMsg : Operation select on client side (=XXX , PPFSOCKET , STOP)   \n"
+         << "   serverName : Name or IP adress of the machine where tsok S is running \n" 
+         << "   NLoop,SizeX,SizeY: Number of transfers, 2D array size for OPEMsg=PPFSOCKET \n" << endl;
+    return 1;
+  }  
+  bool fgserv = false;
+  if (*arg[1] == 'S')  fgserv = true;
+  string servname = "localhost";
+  if (narg > 2)  servname = arg[2];
+  string opemsg = "Hello";
+  if (narg > 3) opemsg = arg[3];
+  string oargs = "1,100,50";
+  if (narg > 4) oargs = arg[4];
+
+  try {
+    SophyaInit();  
+    InitTim(); 
+    if (fgserv) serverside();
+    else if (*arg[1] == 'C') clientside(servname, opemsg, oargs);
+    else burawtst();
+  }
+  catch(PThrowable exc ) {
+    cerr << "tsok-main() , Catched exception: \n" << exc.Msg() << endl;
+  }
+  catch(std::exception ex) {
+    cerr << "tsok-main() , Catched std::exception " << (string)(ex.what()) << endl;
+  }
+  catch(...) {
+    cerr << "tsok-main() , Catched ... ! " << endl;
+  }
+}
+
+
+/* --Fonction-- */
+void serverside()
+{
+  cout << " ======== tsok.cc / ServerSide ============ " << endl;
+  cout << " Creating server socket ... , PortId= " << PORTID << endl;
+  ServerSocket srv(PORTID, 1);
+  bool fgstop = false;
+  int nc = 0;
+  while (!fgstop) {
+    cout << " Waiting for client connection ... nc=" << nc << endl;
+    Socket skt = srv.WaitClientConnection();
+    nc ++;
+    cout << " Connection established ... nc = " << nc << endl;
+    bool fgbye = false;
+    while (! fgbye) {
+      char buff[256];
+      for(int i=0; i<255; i++) buff[i] = '\0';
+      size_t l = skt.Receive(buff, 256);
+      buff[255] = '\0';
+      cout << "Rcv/len=" << l << "Msg=" << buff << endl;
+      if (l < 1) fgbye = true;
+      else if (strncmp(buff,"STOP",4) == 0) fgstop = true;
+      else if (strncmp(buff,"BYE",3) == 0) fgbye = true;
+      else if (strncmp(buff,"PPFSOCKET", 9) == 0) {
+        int nloop = 1;
+        int sx = 100;
+        int sy = 100;
+        sscanf(buff+10,"%d,%d,%d",&nloop, &sx, &sy);
+	cout << " ServerSide: Test SocketStream NLoop= " << nloop 
+             << " Sx= " << sx << " Sy=" << sy << endl;
+        Timer tm("tsok/Server");
+        size_t totnkb = 0;
+        for(int kl=0; kl<nloop; kl++) {
+          ostringstream oss; 
+          oss << " ServerSide/PPFSocket[" << kl <<"]"; 
+          tm.Split(oss.str().c_str());
+//          tm.Split("Server/StartRead");
+          TMatrix<int_4> mx;
+	//	cout << " waiting ... sleep(1) " << endl;
+	//	sleep(1);
+          {
+	  RawInOutSocketStream sstr(skt);
+	  PInPersist pis(&sstr, false, false);
+	  pis.GetObject(mx);
+	  }
+	  if (kl%5 == 0)  mx.Show() ;
+          for(sa_size_t ir=0; ir<mx.NRows(); ir++)
+            mx.Row(ir) += (int_4)(ir+3);
+	  {
+          // cout << " --- writing back modified mx to socket stream ... " << endl;
+	  RawInOutSocketStream sstr(skt);
+	  POutPersist pos(&sstr, false);
+	  pos.PutObject(mx);
+	  }
+          tm.Split("WriteBackDone");
+          float tmillis = tm.PartialElapsedTime()*1000.;
+          if (tmillis < 1.e-5) tmillis = 1e-5;
+          cout << "ServerSide-Rate=" << 2.*(float)(mx.Size()*4)/tmillis << " kbytes/sec" << endl;
+          totnkb += 2*mx.Size()*4/1000;
+
+        }  // fin boucle kl->nloop
+
+        float ttms  = tm.TotalElapsedTime();
+        if (ttms < 1.e-6) ttms = 1e-6;
+        cout << "  ===> Server/PPFSocket-MeanRate= " << (float)totnkb/ttms << " kbytes/sec" << endl;
+      }  // fin if(PPFSOCKET)
+    }  // fin while(! fgbye) 
+    cout << "ServerSide: Closing current socket ..." << endl;
+    skt.Close();
+  }  // fin while(!fgstop)
+  cout << " ======= End of tsok.cc / ServerSide ======== " << endl;
+}
+
+/* --Fonction-- */
+void clientside(string& servname, string& msg, string& args)
+{
+  cout << " ======== tsok.cc / ClientSide ============ " << endl;
+  cout << "  ServerName= " << servname << " OpeMsg= " << msg << endl;
+  cout << "  Creating client socket  ServerName= " << servname << endl;
+  ClientSocket cli(servname, PORTID);
+  char buff[256];
+  string maa = msg;
+  if (msg == "PPFSOCKET")  { maa += ' '; maa += args; } 
+  strncpy(buff, maa.c_str(), 255);
+  buff[255] = '\0';
+  cout << "  Sending Message : " << buff << endl;
+  cli.Send(buff, 256);
+  if (msg == "PPFSOCKET") {
+    int nloop = 1;
+    int sx = 100;
+    int sy = 100;
+    sscanf(args.c_str(),"%d,%d,%d",&nloop, &sx, &sy);
+    cout << " ClientSide: Test SocketStream NLoop= " << nloop 
+         << " Sx= " << sx << " Sy=" << sy << endl;
+    Timer tm("tsok/Client");
+    size_t totnkb = 0;
+    int npb = 0;
+    for(int kl=0; kl<nloop; kl++) {
+      ostringstream oss; 
+      oss << "ClientSide/PPFSocket[" << kl <<"]";
+      tm.Split(oss.str().c_str());
+//      tm.Split("Client/StartSend");
+      TMatrix<int_4> mx(sy, sx);
+      //	cout << " waiting ... sleep(1) " << endl;
+      mx = RandomSequence(RandomSequence::Flat, 50, 10);
+      {
+      // cout << " --- writing mx to socket stream ... " << endl;
+      RawInOutSocketStream sstr(cli);
+      POutPersist pos(&sstr, false);
+      pos.PutObject(mx);
+      }
+      TMatrix<int_4> mxr;
+      {
+      RawInOutSocketStream sstr(cli);
+      PInPersist pis(&sstr, false, false);
+      pis.GetObject(mxr);
+      }
+      if (kl%5==0) mxr.Show();
+      for(sa_size_t ir=0; ir<mx.NRows(); ir++)  {
+        mxr.Row(ir) -= (int_4)(ir+3);
+        mxr.Row(ir) -= mx.Row(ir);
+      }
+     // Check for correct return matrix
+      int_4 rmin, rmax;
+      mxr.MinMax(rmin, rmax);
+      if ((rmin!=0) || (rmax!=0))  npb++;
+      cout << " ClientSide/CheckReturnMinMax=" << rmin << "," << rmax << endl;
+      tm.Split("ReadCheckDone");
+      float tmillis = tm.PartialElapsedTime()*1000.;
+      if (tmillis < 1.e-5) tmillis = 1e-5;
+      cout << "ClientSide-Rate=" << 2.*(float)(mx.Size()*4)/tmillis << " kbytes/sec" << endl;
+      totnkb += 2*mx.Size()*4/1000;
+    }
+    cout << "ClientSide/End of PPFSocket  NPb-Check-returnMatrix=" << npb << " /NLoop=" << nloop << endl;  
+    float ttms  = tm.TotalElapsedTime();
+    if (ttms < 1.e-6) ttms = 1e-6;
+    cout << "  ===> MeanRate= " << (float)totnkb/ttms << " kbytes/sec" << endl;
+  }
+  strncpy(buff, "BYE", 255);
+  cout << "  Sending Message : " << buff << endl;
+  cli.Send(buff, 256);
+  cout << " ======= End of tsok.cc / ClientSide ======== " << endl;
+}
+
+
+/* --Fonction-- */
+void burawtst()
+{
+  cout << " --------- burawtst() ------------ " << endl;
+  {
+    char buff[10000];
+    for(int k=0; k<10000; k++) buff[k] = k%256;
+    RawInOutBuffStream sstr("xxx.str");
+    for(int i=1; i<10; i++) {
+      cout << "Appel RawInOutBuffStream.write(s, " << i*650 << endl;
+      sstr.write(buff, i*650);
+    }
+  }
+  Matrix mx(8,6);
+  mx = RegularSequence();
+  cout << mx;
+  {
+    cout << " --- writing mx to buff stream ... " << endl;
+    RawInOutBuffStream sstr("ftsok.str");
+    POutPersist pos(&sstr, false);
+    pos.PutObject(mx);
+  }
+  {
+    cout << " --- writing mx to file ... " << endl;
+    POutPersist pos("ftsok.ppf");
+    pos.PutObject(mx);
+  }
+
+  cout << " --------- FIN-burawtst() ------------ " << endl;
+  
+}
Index: /trunk/AddOn/TAcq/tstminifits.cc
===================================================================
--- /trunk/AddOn/TAcq/tstminifits.cc	(revision 3541)
+++ /trunk/AddOn/TAcq/tstminifits.cc	(revision 3542)
@@ -40,21 +40,33 @@
   int rc = 0;
   try {
-  	{
+    {
     cout << "1/ Creation tableau " << endl;
     size_t sx = 300;
     size_t sy = 200; 
     TArray<int_2> ta(sx, sy);
+    TArray<r_4> arr(sx, sy);
     ta = RegularSequence(0.,0.5);
     ta.Show();
-    cout << "2/ ecriture tableau ds tmf.ppf " << endl;
+    arr = RandomSequence(RandomSequence::Gaussian, 510.,30.); 
+    arr.Show();
+    cout << "2/ ecriture tableaux ta (int_2) arr (r_4) ds tmf.ppf " << endl;
     POutPersist po("tmf.ppf");
-    po << ta;
+    po << ta << arr;
     cout << "3/ ecriture tableau ds tmf.fits " << endl;
+    {
+    MiniFITSFile mff;
+    mff.setDTypeNaxis(MF_Float32, sx, sy);
+    mff.Open("tmf.fits", MF_Write);
+    mff.WriteI(ta.Data(), sx*sy);
+    }
+    cout << "3.b/ ecriture tableau arr (r_4) ds tmf2.fits " << endl;
+    {
     MiniFITSFile mff;
     mff.setDTypeNaxis(MF_Int16, sx, sy);
-    mff.Open("tmf.fits", MF_Write);
-    mff.WriteI(ta.Data(), sx*sy);
-    cout << "3.b/ FIN ecriture tableau ds tmf.fits " << endl;   
-  	}
+    mff.Open("tmf2.fits", MF_Write);
+    mff.WriteF(arr.Data(), sx*sy);
+    }
+    cout << "3.c/ FIN ecriture tableau ds tmf.fits " << endl;   
+    }
 //  --------------  Ecriture de bytes par morceaux 
     {
