From c01e9dc8d6542fea12e2a70eef9521d73817abbd Mon Sep 17 00:00:00 2001 From: Takuya ASADA Date: Fri, 28 Nov 2014 04:17:10 +0900 Subject: [PATCH] Add file_desc::connect() Signed-off-by: Takuya ASADA --- core/posix.hh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/posix.hh b/core/posix.hh index eb8a6a7686..433def40b4 100644 --- a/core/posix.hh +++ b/core/posix.hh @@ -196,6 +196,13 @@ public: auto r = ::bind(_fd, &sa, sl); throw_system_error_on(r == -1); } + void connect(sockaddr& sa, socklen_t sl) { + auto r = ::connect(_fd, &sa, sl); + if (r == -1 && errno == EINPROGRESS) { + return; + } + throw_system_error_on(r == -1); + } socket_address get_address() { socket_address addr; auto len = (socklen_t) sizeof(addr.u.sas);