]>
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
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_SOCKETS && wxUSE_STREAMS
20 #include "wx/sckstrm.h"
23 #include "wx/stream.h"
26 #include "wx/socket.h"
28 // ---------------------------------------------------------------------------
29 // wxSocketOutputStream
30 // ---------------------------------------------------------------------------
32 wxSocketOutputStream::wxSocketOutputStream(wxSocketBase
& s
)
37 wxSocketOutputStream::~wxSocketOutputStream()
41 size_t wxSocketOutputStream::OnSysWrite(const void *buffer
, size_t size
)
43 const size_t ret
= m_o_socket
->Write(buffer
, size
).LastCount();
44 m_lasterror
= m_o_socket
->Error()
45 ? m_o_socket
->IsClosed() ? wxSTREAM_EOF
46 : wxSTREAM_WRITE_ERROR
51 // ---------------------------------------------------------------------------
52 // wxSocketInputStream
53 // ---------------------------------------------------------------------------
55 wxSocketInputStream::wxSocketInputStream(wxSocketBase
& s
)
60 wxSocketInputStream::~wxSocketInputStream()
64 size_t wxSocketInputStream::OnSysRead(void *buffer
, size_t size
)
66 const size_t ret
= m_i_socket
->Read(buffer
, size
).LastCount();
67 m_lasterror
= m_i_socket
->Error()
68 ? m_i_socket
->IsClosed() ? wxSTREAM_EOF
74 // ---------------------------------------------------------------------------
76 // ---------------------------------------------------------------------------
78 wxSocketStream::wxSocketStream(wxSocketBase
& s
)
79 : wxSocketInputStream(s
), wxSocketOutputStream(s
)
83 wxSocketStream::~wxSocketStream()
87 #endif // wxUSE_STREAMS && wxUSE_SOCKETS