]> git.saurik.com Git - wxWidgets.git/blame - src/common/sckstrm.cpp
fix building with WXWIN_COMPATIBILITY_2_8 == 0
[wxWidgets.git] / src / common / sckstrm.cpp
CommitLineData
f4ada568 1/////////////////////////////////////////////////////////////////////////////
8898456d 2// Name: src/common/sckstrm.cpp
f4ada568
GL
3// Purpose: wxSocket*Stream
4// Author: Guilhem Lavaux
5// Modified by:
6// Created: 17/07/97
f4ada568 7// Copyright: (c)
65571936 8// Licence: wxWindows licence
f4ada568 9/////////////////////////////////////////////////////////////////////////////
f4ada568 10
fcc6dddd
JS
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
8898456d 15 #pragma hdrstop
fcc6dddd
JS
16#endif
17
8898456d
WS
18#if wxUSE_SOCKETS && wxUSE_STREAMS
19
530ecef0
WS
20#include "wx/sckstrm.h"
21
fcc6dddd 22#ifndef WX_PRECOMP
530ecef0 23 #include "wx/stream.h"
fcc6dddd
JS
24#endif
25
f4ada568 26#include "wx/socket.h"
f4ada568
GL
27
28// ---------------------------------------------------------------------------
29// wxSocketOutputStream
30// ---------------------------------------------------------------------------
31
32wxSocketOutputStream::wxSocketOutputStream(wxSocketBase& s)
33 : m_o_socket(&s)
34{
35}
36
37wxSocketOutputStream::~wxSocketOutputStream()
38{
39}
40
375abe3d
GL
41size_t wxSocketOutputStream::OnSysWrite(const void *buffer, size_t size)
42{
c9157492
VZ
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
47 : wxSTREAM_NO_ERROR;
7e134dc1 48 return ret;
375abe3d
GL
49}
50
f4ada568
GL
51// ---------------------------------------------------------------------------
52// wxSocketInputStream
53// ---------------------------------------------------------------------------
54
55wxSocketInputStream::wxSocketInputStream(wxSocketBase& s)
56 : m_i_socket(&s)
57{
58}
59
60wxSocketInputStream::~wxSocketInputStream()
61{
62}
63
375abe3d
GL
64size_t wxSocketInputStream::OnSysRead(void *buffer, size_t size)
65{
c9157492
VZ
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
69 : wxSTREAM_READ_ERROR
70 : wxSTREAM_NO_ERROR;
7e134dc1 71 return ret;
375abe3d
GL
72}
73
f4ada568 74// ---------------------------------------------------------------------------
75ed1d15 75// wxSocketStream
f4ada568 76// ---------------------------------------------------------------------------
f4ada568
GL
77
78wxSocketStream::wxSocketStream(wxSocketBase& s)
79 : wxSocketInputStream(s), wxSocketOutputStream(s)
80{
81}
75ed1d15
GL
82
83wxSocketStream::~wxSocketStream()
84{
85}
35a4dab7 86
74a50e49 87#endif // wxUSE_STREAMS && wxUSE_SOCKETS