**
** DESCRIPTION : sockbuf and sockstream classes.
**
+** Special thanks to Marc Groenewegen <marcg@dinkum.nl>
+**
** EXPORTED OBJECTS : class sockbuf, class isockstream,
** class osockstream, class sockstream
** LOCAL OBJECTS :
********************************
** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
** CREATION DATE : Aug 16, 2012
-** LAST UPDATE : Oct 19, 2012
+** LAST UPDATE : Nov 13, 2012
** MODIFICATIONS :
**************************************************************************/
**
** RELATIONS :
** SEE ALSO :
-** LAST MODIFIED : Oct 19, 2012
+** LAST MODIFIED : Nov 13, 2012
**+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
this->init(&_M_sockbuf);
_M_sockbuf.connect(_s);
}
+
+ void close()
+ {
+ _M_sockbuf.close();
+ }
};
**
** RELATIONS :
** SEE ALSO :
-** LAST MODIFIED : Oct 19, 2012
+** LAST MODIFIED : Nov 13, 2012
**+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
this->init(&_M_sockbuf);
_M_sockbuf.connect(_s);
}
+
+ void close()
+ {
+ _M_sockbuf.close();
+ }
};
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
**
** RELATIONS :
** SEE ALSO :
-** LAST MODIFIED : Oct 19, 2012
+** LAST MODIFIED : Nov 13, 2012
**+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
this->init(&_M_sockbuf);
_M_sockbuf.connect(_s);
}
+
+ void close()
+ {
+ _M_sockbuf.close();
+ }
};
iptest_CPPFLAGS = -I$(top_srcdir)/include
iptest_LDADD = $(top_builddir)/src/libsockstream.la
-http_get_SOURCES = iptest.cpp
+http_get_SOURCES = http_get.cpp
http_get_CPPFLAGS = -I$(top_srcdir)/include
http_get_LDADD = $(top_builddir)/src/libsockstream.la
**************************************************************************/
-#include "socket.h"
+#include "sockstream.h"
/*=========================================================================
StreamSocket s;
s.Listen(sa);
- while (true)
- {
- char buf[1000];
+ //while (true)
+ //{
int len;
- StreamSocket client = s.Accept();
+ sockstream client(s.Accept());
std::cout << "Socket connected.\n";
do
{
- char reverse[1000];
+ String buf, reverse;
- buf[0] = '\0';
- len = client.Read(buf, 1000);
- buf[len] = '\0';
+ client >> buf;
+ len = ~buf;
+ reverse = "";
std::cout << "\nLEN = " << len << "\n" << buf << "\n";
for (int i = 0; i < len; i++)
{
- reverse[i] = buf[len-i-1];
+ reverse += buf(len-i-1, 1);
}
- client.Write(reverse, len);
+ client << reverse << std::endl;
}
- while (len > 0);
- client.Close();
- }
+ while (len > 2);
+ client.close();
+ //}
}