]>
Commit | Line | Data |
---|---|---|
f4ada568 GL |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: sckstrm.h | |
3 | // Purpose: wxSocket*Stream | |
4 | // Author: Guilhem Lavaux | |
5 | // Modified by: | |
6 | // Created: 17/07/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | #ifdef __GNUG__ | |
12 | #pragma implementation "sckstrm.h" | |
13 | #endif | |
14 | ||
fcc6dddd JS |
15 | // For compilers that support precompilation, includes "wx.h". |
16 | #include "wx/wxprec.h" | |
17 | ||
18 | #ifdef __BORLANDC__ | |
ce4169a4 | 19 | #pragma hdrstop |
fcc6dddd JS |
20 | #endif |
21 | ||
22 | #ifndef WX_PRECOMP | |
ce4169a4 | 23 | #include "wx/defs.h" |
fcc6dddd JS |
24 | #endif |
25 | ||
ce4169a4 RR |
26 | #if wxUSE_SOCKETS && wxUSE_STREAMS |
27 | ||
f4ada568 GL |
28 | #include "wx/stream.h" |
29 | #include "wx/socket.h" | |
30 | #include "wx/sckstrm.h" | |
31 | ||
32 | // --------------------------------------------------------------------------- | |
33 | // wxSocketOutputStream | |
34 | // --------------------------------------------------------------------------- | |
35 | ||
36 | wxSocketOutputStream::wxSocketOutputStream(wxSocketBase& s) | |
37 | : m_o_socket(&s) | |
38 | { | |
39 | } | |
40 | ||
41 | wxSocketOutputStream::~wxSocketOutputStream() | |
42 | { | |
43 | } | |
44 | ||
45 | wxOutputStream& wxSocketOutputStream::Write(const void *buffer, size_t size) | |
46 | { | |
75ed1d15 | 47 | m_lastcount = m_o_socket->Write((const char *)buffer, size).LastCount(); |
f4ada568 GL |
48 | return *this; |
49 | } | |
50 | ||
375abe3d GL |
51 | size_t wxSocketOutputStream::OnSysWrite(const void *buffer, size_t size) |
52 | { | |
53 | return m_o_socket->Write((const char *)buffer, size).LastCount(); | |
54 | } | |
55 | ||
f4ada568 GL |
56 | // --------------------------------------------------------------------------- |
57 | // wxSocketInputStream | |
58 | // --------------------------------------------------------------------------- | |
59 | ||
60 | wxSocketInputStream::wxSocketInputStream(wxSocketBase& s) | |
61 | : m_i_socket(&s) | |
62 | { | |
63 | } | |
64 | ||
65 | wxSocketInputStream::~wxSocketInputStream() | |
66 | { | |
67 | } | |
68 | ||
69 | wxInputStream& wxSocketInputStream::Read(void *buffer, size_t size) | |
70 | { | |
75ed1d15 | 71 | m_lastcount = m_i_socket->Read((char *)buffer, size).LastCount(); |
f4ada568 GL |
72 | return *this; |
73 | } | |
74 | ||
375abe3d GL |
75 | size_t wxSocketInputStream::OnSysRead(void *buffer, size_t size) |
76 | { | |
77 | return m_i_socket->Read((char *)buffer, size).LastCount(); | |
78 | } | |
79 | ||
f4ada568 | 80 | // --------------------------------------------------------------------------- |
75ed1d15 | 81 | // wxSocketStream |
f4ada568 | 82 | // --------------------------------------------------------------------------- |
f4ada568 GL |
83 | |
84 | wxSocketStream::wxSocketStream(wxSocketBase& s) | |
85 | : wxSocketInputStream(s), wxSocketOutputStream(s) | |
86 | { | |
87 | } | |
75ed1d15 GL |
88 | |
89 | wxSocketStream::~wxSocketStream() | |
90 | { | |
91 | } | |
35a4dab7 GL |
92 | |
93 | #endif | |
ce4169a4 | 94 | // wxUSE_STREAMS && wxUSE_SOCKETS |