1 #ifndef _NET_SOCKET_STREAM_H_
2 #define _NET_SOCKET_STREAM_H_
51 setp(out_buf, out_buf + out_len);
56 if(pptr() != pbase()) {
59 while(pbase() + len < pptr()) {
60 n = socket.
Send(pbase() + len, pptr() - pbase() - len);
65 setp(out_buf, out_buf + out_len);
73 sum += (egptr() - eback());
74 int len = socket.
Receive(in_buf, in_len);
76 if(len <= 0)
return traits_type::eof();
78 setg(in_buf, in_buf, in_buf + len);
79 return traits_type::to_int_type(*gptr());
85 if(traits_type::eq_int_type(traits_type::eof(), c))
return sync();
87 if(pptr() == epptr())
sync();
89 traits_type::assign(*pptr(), traits_type::to_char_type(c));
98 return (sum + (egptr() - eback()));
Class derived from the STL std::streambuf to allow streaming with sockets.
Definition: socket_stream.h:23
Socket * operator->()
Definition: socket_stream.h:131
int in_len
Definition: socket_stream.h:27
int sum
Definition: socket_stream.h:26
char * in_buf
Definition: socket_stream.h:29
int Receive(void *buf, int len, bool prevent_block=false)
Receives a number of bytes.
Definition: socket.cc:57
int out_len
Definition: socket_stream.h:28
virtual int_type overflow(int_type c=EOF)
Definition: socket_stream.h:83
Contains classes to easy the utilization of sockets, specially implemented for UNIX systems...
Definition: address.h:15
virtual int sync()
Definition: socket_stream.h:54
int GetReadBytes() const
Definition: socket_stream.h:96
Socket socket
Definition: socket_stream.h:31
SocketStream(int sid, int in_len=INPUT_BUFFER_LENGTH, int out_len=OUTPUT_BUFFER_LENGTH)
Definition: socket_stream.h:124
Definition: socket_stream.h:36
int Send(void *buf, int len, bool prevent_block=false)
Sends a number of bytes.
Definition: socket.cc:79
Class derived from std::iostream and SocketBuffer that represents a socket stream.
Definition: socket_stream.h:121
virtual int_type underflow()
Definition: socket_stream.h:71
virtual ~SocketStream()
Definition: socket_stream.h:136
char * out_buf
Definition: socket_stream.h:30
virtual ~SocketBuffer()
Definition: socket_stream.h:106
SocketBuffer(int sid, int in_len=INPUT_BUFFER_LENGTH, int out_len=OUTPUT_BUFFER_LENGTH)
Definition: socket_stream.h:39
Definition: socket_stream.h:35
Socket * GetSocket()
Definition: socket_stream.h:101
This class has been designed to work with UNIX sockets in an easy and object oriented way...
Definition: socket.h:28