5 #include <sys/socket.h>
7 #include <msp/core/systemerror.h>
8 #include "clientsocket.h"
9 #include "socket_private.h"
14 ClientSocket::ClientSocket(Family af, int type, int proto):
15 Socket(af, type, proto),
21 ClientSocket::ClientSocket(const Private &p, const SockAddr &paddr):
25 peer_addr(paddr.copy())
28 ClientSocket::~ClientSocket()
30 signal_flush_required.emit();
35 void ClientSocket::shutdown(IO::Mode m)
42 else if(m==IO::M_WRITE)
44 else if(m==IO::M_RDWR)
49 else if(m==IO::M_WRITE)
51 else if(m==IO::M_RDWR)
57 ::shutdown(priv->handle, how);
61 const SockAddr &ClientSocket::get_peer_address() const
64 throw bad_socket_state("not connected");
68 unsigned ClientSocket::do_write(const char *buf, unsigned size)
70 check_access(IO::M_WRITE);
72 throw bad_socket_state("not connected");
77 int ret = ::send(priv->handle, buf, size, 0);
83 throw system_error("send");
89 unsigned ClientSocket::do_read(char *buf, unsigned size)
91 check_access(IO::M_READ);
93 throw bad_socket_state("not connected");
98 int ret = ::recv(priv->handle, buf, size, 0);
104 throw system_error("recv");
106 else if(ret==0 && !eof_flag)
109 signal_end_of_file.emit();
110 set_events(IO::P_NONE);