Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
90ba9418
Commit
90ba9418
authored
Jun 05, 2015
by
Jonathan Williamson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix "bind: Address already in use" error if restart before socket is free
parent
11090500
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
main.c
main.c
+5
-1
No files found.
main.c
View file @
90ba9418
...
@@ -892,13 +892,17 @@ int main (int argc, char **argv) {
...
@@ -892,13 +892,17 @@ int main (int argc, char **argv) {
if
(
port
>
0
)
{
if
(
port
>
0
)
{
struct
sockaddr_in
serv_addr
;
struct
sockaddr_in
serv_addr
;
int
yes
=
1
;
sfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
sfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
sfd
<
0
)
{
if
(
sfd
<
0
)
{
perror
(
"socket"
);
perror
(
"socket"
);
exit
(
1
);
exit
(
1
);
}
}
if
(
setsockopt
(
sfd
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
yes
,
sizeof
(
int
))
<
0
)
{
perror
(
"setsockopt"
);
exit
(
1
);
}
memset
(
&
serv_addr
,
0
,
sizeof
(
serv_addr
));
memset
(
&
serv_addr
,
0
,
sizeof
(
serv_addr
));
serv_addr
.
sin_family
=
AF_INET
;
serv_addr
.
sin_family
=
AF_INET
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment