1 #include "platform_api.h"
2 #include <msp/core/systemerror.h>
3 #include "clientsocket.h"
4 #include "socket_private.h"
9 ClientSocket::ClientSocket(Family af, int type, int proto):
10 Socket(af, type, proto),
16 ClientSocket::ClientSocket(const Private &p, const SockAddr &paddr):
20 peer_addr(paddr.copy())
23 ClientSocket::~ClientSocket()
25 signal_flush_required.emit();
30 void ClientSocket::shutdown(IO::Mode m)
37 else if(m==IO::M_WRITE)
39 else if(m==IO::M_RDWR)
44 else if(m==IO::M_WRITE)
46 else if(m==IO::M_RDWR)
52 ::shutdown(priv->handle, how);
56 const SockAddr &ClientSocket::get_peer_address() const
59 throw bad_socket_state("not connected");
63 unsigned ClientSocket::do_write(const char *buf, unsigned size)
65 check_access(IO::M_WRITE);
67 throw bad_socket_state("not connected");
72 return check_sys_error(::send(priv->handle, buf, size, 0), "send");
75 unsigned ClientSocket::do_read(char *buf, unsigned size)
77 check_access(IO::M_READ);
79 throw bad_socket_state("not connected");
84 unsigned ret = check_sys_error(::recv(priv->handle, buf, size, 0), "recv");
85 if(ret==0 && !eof_flag)
88 signal_end_of_file.emit();
89 set_socket_events(S_NONE);