3 #include <sys/socket.h>
5 #include <msp/core/systemerror.h>
6 #include "clientsocket.h"
7 #include "socket_private.h"
12 ClientSocket::ClientSocket(Family af, int type, int proto):
13 Socket(af, type, proto),
19 ClientSocket::ClientSocket(const Private &p, const SockAddr &paddr):
23 peer_addr(paddr.copy())
26 ClientSocket::~ClientSocket()
28 signal_flush_required.emit();
33 const SockAddr &ClientSocket::get_peer_address() const
36 throw bad_socket_state("not connected");
40 unsigned ClientSocket::do_write(const char *buf, unsigned size)
43 throw bad_socket_state("not connected");
48 int ret = ::send(priv->handle, buf, size, 0);
54 throw system_error("send");
60 unsigned ClientSocket::do_read(char *buf, unsigned size)
63 throw bad_socket_state("not connected");
68 int ret = ::recv(priv->handle, buf, size, 0);
74 throw system_error("recv");
76 else if(ret==0 && !eof_flag)
79 signal_end_of_file.emit();
80 set_events(IO::P_NONE);