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