]>
Commit | Line | Data |
---|---|---|
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 | ||
15 | // For compilers that support precompilation, includes "wx.h". | |
16 | #include "wx/wxprec.h" | |
17 | ||
18 | #ifdef __BORLANDC__ | |
19 | #pragma hdrstop | |
20 | #endif | |
21 | ||
22 | #ifndef WX_PRECOMP | |
23 | #include "wx/defs.h" | |
24 | #endif | |
25 | ||
26 | #if wxUSE_SOCKETS && wxUSE_STREAMS | |
27 | ||
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 | size_t wxSocketOutputStream::OnSysWrite(const void *buffer, size_t size) | |
46 | { | |
47 | size_t ret = m_o_socket->Write((const char *)buffer, size).LastCount(); | |
48 | ||
49 | m_lasterror = m_o_socket->Error() ? wxSTREAM_WRITE_ERROR : wxSTREAM_NO_ERROR; | |
50 | ||
51 | return ret; | |
52 | } | |
53 | ||
54 | // --------------------------------------------------------------------------- | |
55 | // wxSocketInputStream | |
56 | // --------------------------------------------------------------------------- | |
57 | ||
58 | wxSocketInputStream::wxSocketInputStream(wxSocketBase& s) | |
59 | : m_i_socket(&s) | |
60 | { | |
61 | } | |
62 | ||
63 | wxSocketInputStream::~wxSocketInputStream() | |
64 | { | |
65 | } | |
66 | ||
67 | size_t wxSocketInputStream::OnSysRead(void *buffer, size_t size) | |
68 | { | |
69 | size_t ret = m_i_socket->Read((char *)buffer, size).LastCount(); | |
70 | ||
71 | m_lasterror = m_i_socket->Error() ? wxSTREAM_READ_ERROR : wxSTREAM_NO_ERROR; | |
72 | ||
73 | return ret; | |
74 | } | |
75 | ||
76 | // --------------------------------------------------------------------------- | |
77 | // wxSocketStream | |
78 | // --------------------------------------------------------------------------- | |
79 | ||
80 | wxSocketStream::wxSocketStream(wxSocketBase& s) | |
81 | : wxSocketInputStream(s), wxSocketOutputStream(s) | |
82 | { | |
83 | } | |
84 | ||
85 | wxSocketStream::~wxSocketStream() | |
86 | { | |
87 | } | |
88 | ||
89 | #endif | |
90 | // wxUSE_STREAMS && wxUSE_SOCKETS |