diff options
author | 2018-04-16 16:15:40 +0200 | |
---|---|---|
committer | 2018-04-16 16:15:40 +0200 | |
commit | 55fcef04efd44321ceae02d68a3c18fbf90f5ad9 (patch) | |
tree | f324982c6e30b6fe66927329c62465ba71eb3054 /src/osd/modules/file | |
parent | ed3345e84f024fdfe4e52a9a13469f8747fa45ce (diff) |
Set SO_REUSEADDR in posixsocket
Without it you have to wait until the socket is moved
out of the TIME_WAIT state, which can take quite a while.
This is pretty anoying when using mame with serial ports
forwarded via TCP.
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Diffstat (limited to 'src/osd/modules/file')
-rw-r--r-- | src/osd/modules/file/posixsocket.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/osd/modules/file/posixsocket.cpp b/src/osd/modules/file/posixsocket.cpp index d6655e4cf15..edb95816077 100644 --- a/src/osd/modules/file/posixsocket.cpp +++ b/src/osd/modules/file/posixsocket.cpp @@ -176,6 +176,14 @@ osd_file::error posix_open_socket(std::string const &path, std::uint32_t openfla return errno_to_file_error(err); } + if (::setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<const char *>(&flag), sizeof(flag)) < 0) + { + int const err = errno; + ::close(sock); + return errno_to_file_error(err); + } + + // listening socket support if (openflags & OPEN_FLAG_CREATE) { |