projects
/
nbd.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e472e06
)
r16: Set SO_REUSEADDR socket option to nbd-server
author
yoe <yoe>
Mon, 28 Jan 2002 23:05:08 +0000
(23:05 +0000)
committer
yoe <yoe>
Mon, 28 Jan 2002 23:05:08 +0000
(23:05 +0000)
nbd-server.c
patch
|
blob
|
history
diff --git
a/nbd-server.c
b/nbd-server.c
index
3763d5a
..
eb18f5e
100644
(file)
--- a/
nbd-server.c
+++ b/
nbd-server.c
@@
-212,10
+212,20
@@
void connectme(int port)
struct sockaddr_in addrin;
int addrinlen = sizeof(addrin);
int net, sock, newpid;
struct sockaddr_in addrin;
int addrinlen = sizeof(addrin);
int net, sock, newpid;
+#ifndef sun
+ int yes=1;
+#else
+ char yes='1';
+#endif
if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
err("socket: %m");
if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
err("socket: %m");
+ /* lose the pesky "Address already in use" error message */
+ if (setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) == -1) {
+ err("setsockopt");
+ }
+
DEBUG("Waiting for connections... bind, ");
addrin.sin_family = AF_INET;
addrin.sin_port = htons(port);
DEBUG("Waiting for connections... bind, ");
addrin.sin_family = AF_INET;
addrin.sin_port = htons(port);