mirror of https://github.com/Genymobile/scrcpy
Reuse server address
Set SO_REUSEADDR flag to server socket, so that bind() does not fail if we restart scrcpy immediately after we closed the previous one.
This commit is contained in:
parent
6db22ef339
commit
60f3185185
|
@ -25,6 +25,11 @@ socket_t net_listen(Uint32 addr, Uint16 port, int backlog) {
|
|||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
int reuse = 1;
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const void *) &reuse, sizeof(reuse)) == -1) {
|
||||
perror("setsockopt(SO_REUSEADDR)");
|
||||
}
|
||||
|
||||
SOCKADDR_IN sin;
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr.s_addr = htonl(addr); // htonl() harmless on INADDR_ANY
|
||||
|
|
Loading…
Reference in New Issue