]>
git.saurik.com Git - wxWidgets.git/blob - src/common/sckstrm.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/sckstrm.cpp
3 // Purpose: wxSocket*Stream
4 // Author: Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
19 #if wxUSE_SOCKETS && wxUSE_STREAMS
21 #include "wx/sckstrm.h"
24 #include "wx/stream.h"
27 #include "wx/socket.h"
29 // ---------------------------------------------------------------------------
30 // wxSocketOutputStream
31 // ---------------------------------------------------------------------------
33 wxSocketOutputStream::wxSocketOutputStream(wxSocketBase
& s
)
38 wxSocketOutputStream::~wxSocketOutputStream()
42 size_t wxSocketOutputStream::OnSysWrite(const void *buffer
, size_t size
)
44 const size_t ret
= m_o_socket
->Write(buffer
, size
).LastCount();
45 m_lasterror
= m_o_socket
->Error()
46 ? m_o_socket
->IsClosed() ? wxSTREAM_EOF
47 : wxSTREAM_WRITE_ERROR
52 // ---------------------------------------------------------------------------
53 // wxSocketInputStream
54 // ---------------------------------------------------------------------------
56 wxSocketInputStream::wxSocketInputStream(wxSocketBase
& s
)
61 wxSocketInputStream::~wxSocketInputStream()
65 size_t wxSocketInputStream::OnSysRead(void *buffer
, size_t size
)
67 const size_t ret
= m_i_socket
->Read(buffer
, size
).LastCount();
68 m_lasterror
= m_i_socket
->Error()
69 ? m_i_socket
->IsClosed() ? wxSTREAM_EOF
75 // ---------------------------------------------------------------------------
77 // ---------------------------------------------------------------------------
79 wxSocketStream::wxSocketStream(wxSocketBase
& s
)
80 : wxSocketInputStream(s
), wxSocketOutputStream(s
)
84 wxSocketStream::~wxSocketStream()
88 #endif // wxUSE_STREAMS && wxUSE_SOCKETS