int err=::connect(handle, &sa, size);
if(err==-1)
- throw Exception(format("Unable to connect: %s", strerror(errno)));
+ throw SystemError("Unable to connect", errno);
delete peer_addr;
peer_addr=addr.copy();
if(errno==EAGAIN)
return 0;
else
- throw Exception(format("Sendto failed: %s", strerror(errno)));
+ throw SystemError("Sendto failed", errno);
}
return ret;
if(errno==EAGAIN)
return 0;
else
- throw Exception(format("Recvfrom failed: %s", strerror(errno)));
+ throw SystemError("Recvfrom failed", errno);
}
addr_=SockAddr::create(addr);
int err=::bind(handle, &sa, size);
if(err==-1)
- throw Exception(format("Unable to bind: %s", strerror(errno)));
+ throw SystemError("Unable to bind", errno);
delete local_addr;
local_addr=addr.copy();
if(errno==EAGAIN)
return 0;
else
- throw Exception(format("Writing to socket failed: %s", strerror(errno)));
+ throw SystemError("Writing to socket failed", errno);
}
return ret;
if(errno==EAGAIN)
return 0;
else
- throw Exception(format("Reading from socket failed: %s", strerror(errno)));
+ throw SystemError("Reading from socket failed", errno);
}
else if(ret==0 && !eof_flag)
{
Distributed under the LGPL
*/
-#include <errno.h>
+#include <cerrno>
#include <msp/core/refptr.h>
#include <msp/strings/formatter.h>
#include "streamlistensocket.h"
int err=::listen(handle, backlog);
if(err==-1)
- throw Exception(format("Unable to listen: %s", strerror(errno)));
+ throw SystemError("Unable to listen", errno);
#ifdef WIN32
WSAEventSelect(handle, event, FD_ACCEPT);
#ifndef WIN32
#include <sys/socket.h>
#endif
-#include <errno.h>
+#include <cerrno>
#include <msp/io/poll.h>
#include <msp/strings/formatter.h>
#include "streamsocket.h"
#ifdef WIN32
throw Exception(format("Connection polling failed: %d", WSAGetLastError()));
#else
- throw Exception(format("Connection polling failed: %s", strerror(errno)));
+ throw SystemError("Connection polling failed", errno);
#endif
else if(res>0)
{
#ifdef WIN32
throw Exception(format("Connection failed: %d", err));
#else
- throw Exception(format("Connection failed: %s", strerror(err)));
+ throw SystemError("Connection failed", err);
#endif
}
set_events(IO::P_OUTPUT);
}
else
- throw Exception(format("Unable to connect: %s", strerror(errno)));
+ throw SystemError("Unable to connect", errno);
}
#endif