How does the OS tell whether an “Address is already in use”?How do I tell if employees are using TeamViewer at work?virtualbox and nginx server_namenetstat shows open port with pid for process that doesn't exist?What exactly determines if a backgrounded job is killed when the shell is exited, or killed?How to free a port on OS X when lsof(1) reports that it is not in useClosing a socket which keeps waiting a child process, when the parent process has been killedWhen listening to a port (taskserver) should the local address be `localhost` or `0.0.0.0`?Server stopped but port 3000 still being used and localhost accessible
Does maintaining a spell with a longer casting time count as casting a spell?
Do Bayesian credible intervals treat the estimated parameter as a random variable?
Handling Disruptive Student on the Autism Spectrum
Very slow boot time and poor perfomance
Ordering a list of integers
Why do banks “park” their money at the European Central Bank?
HJM in infinite dimensions
When, exactly, does the Rogue Scout get to use their Skirmisher ability?
Immediate Smaller Element Time Limit Exceeded
Does this VCO produce a sine wave or square wave
Can a giant mushroom be used as a material to build watercraft or sailing ships?
How to gently end involvement with an online community?
Joining lists with same elements
"Opusculum hoc, quamdiu vixero, doctioribus emendandum offero."?
Why is the UK so keen to remove the "backstop" when their leadership seems to think that no border will be needed in Northern Ireland?
How to send bitcoin from an offline Bitcoin Core that doesn't have a synced balance?
Evaluated vs. unevaluated Association
Are the players on the same team as the DM?
What is a natural problem in theory of computation?
Can RMSE and MAE have the same value?
How is linear momentum conserved in case of a freely falling body?
Does ostensible/specious make sense in this sentence?
Why do these two functions have the same bytecode when disassembled under dis.dis?
When one problem is added to the previous one
How does the OS tell whether an “Address is already in use”?
How do I tell if employees are using TeamViewer at work?virtualbox and nginx server_namenetstat shows open port with pid for process that doesn't exist?What exactly determines if a backgrounded job is killed when the shell is exited, or killed?How to free a port on OS X when lsof(1) reports that it is not in useClosing a socket which keeps waiting a child process, when the parent process has been killedWhen listening to a port (taskserver) should the local address be `localhost` or `0.0.0.0`?Server stopped but port 3000 still being used and localhost accessible
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
If my C program uses sockets, binds to localhost:9025
, exchanges some data, gets manually killed and restarted, it sometimes crashes with the error being:
Address already in use.
All SE-recommended software that I've tried to look for “pid that uses port” with have failed to return any process id, so I assume there is no process at that time that uses port 9025
, which should be the case.
Nonetheless, from what I've gathered from comments on topically similar questions, it seemed to me that "Address" is "already in use" if and only if a process uses that particular address. Why is this false then?
Now I assume the OS keeps track of what addresses are in use and what are not, but is that the case? If it is though, I would love if you could tell me how do I correct it, because my best solution to this problem is “wait for an undetermined amount of time”.
EDIT: I use Linux 5.2.2-arch1-1-ARCH x86_64
linux networking c sockets
New contributor
add a comment |
If my C program uses sockets, binds to localhost:9025
, exchanges some data, gets manually killed and restarted, it sometimes crashes with the error being:
Address already in use.
All SE-recommended software that I've tried to look for “pid that uses port” with have failed to return any process id, so I assume there is no process at that time that uses port 9025
, which should be the case.
Nonetheless, from what I've gathered from comments on topically similar questions, it seemed to me that "Address" is "already in use" if and only if a process uses that particular address. Why is this false then?
Now I assume the OS keeps track of what addresses are in use and what are not, but is that the case? If it is though, I would love if you could tell me how do I correct it, because my best solution to this problem is “wait for an undetermined amount of time”.
EDIT: I use Linux 5.2.2-arch1-1-ARCH x86_64
linux networking c sockets
New contributor
Unless using RAW sockets, the OS handles TCP. Did you look for connections in any state after the program failed to restart?
– Daniel B
8 hours ago
I checked the port with netstat, lsof, ss and fuser.
– Captain Trojan
6 hours ago
add a comment |
If my C program uses sockets, binds to localhost:9025
, exchanges some data, gets manually killed and restarted, it sometimes crashes with the error being:
Address already in use.
All SE-recommended software that I've tried to look for “pid that uses port” with have failed to return any process id, so I assume there is no process at that time that uses port 9025
, which should be the case.
Nonetheless, from what I've gathered from comments on topically similar questions, it seemed to me that "Address" is "already in use" if and only if a process uses that particular address. Why is this false then?
Now I assume the OS keeps track of what addresses are in use and what are not, but is that the case? If it is though, I would love if you could tell me how do I correct it, because my best solution to this problem is “wait for an undetermined amount of time”.
EDIT: I use Linux 5.2.2-arch1-1-ARCH x86_64
linux networking c sockets
New contributor
If my C program uses sockets, binds to localhost:9025
, exchanges some data, gets manually killed and restarted, it sometimes crashes with the error being:
Address already in use.
All SE-recommended software that I've tried to look for “pid that uses port” with have failed to return any process id, so I assume there is no process at that time that uses port 9025
, which should be the case.
Nonetheless, from what I've gathered from comments on topically similar questions, it seemed to me that "Address" is "already in use" if and only if a process uses that particular address. Why is this false then?
Now I assume the OS keeps track of what addresses are in use and what are not, but is that the case? If it is though, I would love if you could tell me how do I correct it, because my best solution to this problem is “wait for an undetermined amount of time”.
EDIT: I use Linux 5.2.2-arch1-1-ARCH x86_64
linux networking c sockets
linux networking c sockets
New contributor
New contributor
edited 1 hour ago
MarianD
1,7551 gold badge9 silver badges19 bronze badges
1,7551 gold badge9 silver badges19 bronze badges
New contributor
asked 8 hours ago
Captain TrojanCaptain Trojan
133 bronze badges
133 bronze badges
New contributor
New contributor
Unless using RAW sockets, the OS handles TCP. Did you look for connections in any state after the program failed to restart?
– Daniel B
8 hours ago
I checked the port with netstat, lsof, ss and fuser.
– Captain Trojan
6 hours ago
add a comment |
Unless using RAW sockets, the OS handles TCP. Did you look for connections in any state after the program failed to restart?
– Daniel B
8 hours ago
I checked the port with netstat, lsof, ss and fuser.
– Captain Trojan
6 hours ago
Unless using RAW sockets, the OS handles TCP. Did you look for connections in any state after the program failed to restart?
– Daniel B
8 hours ago
Unless using RAW sockets, the OS handles TCP. Did you look for connections in any state after the program failed to restart?
– Daniel B
8 hours ago
I checked the port with netstat, lsof, ss and fuser.
– Captain Trojan
6 hours ago
I checked the port with netstat, lsof, ss and fuser.
– Captain Trojan
6 hours ago
add a comment |
1 Answer
1
active
oldest
votes
You are probably re-starting your program too fast, or the program is not closing
the socket.
Even after the socket is closed, Linux keeps the connection in limbo for
some time,
but will prevent any other connection from being accepted for the same quadruplet of
"source address, source port, destination address, destination port".
The solution is to set the socket option in the program with
setsockopt
like this:
setsockopt(socket,SOL_SOCKET,SO_REUSEADDR ... )
Ah, I see, that makes sense. Problem seems to have stopped occuring, thank you very much.
– Captain Trojan
6 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "3"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Captain Trojan is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1475140%2fhow-does-the-os-tell-whether-an-address-is-already-in-use%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You are probably re-starting your program too fast, or the program is not closing
the socket.
Even after the socket is closed, Linux keeps the connection in limbo for
some time,
but will prevent any other connection from being accepted for the same quadruplet of
"source address, source port, destination address, destination port".
The solution is to set the socket option in the program with
setsockopt
like this:
setsockopt(socket,SOL_SOCKET,SO_REUSEADDR ... )
Ah, I see, that makes sense. Problem seems to have stopped occuring, thank you very much.
– Captain Trojan
6 hours ago
add a comment |
You are probably re-starting your program too fast, or the program is not closing
the socket.
Even after the socket is closed, Linux keeps the connection in limbo for
some time,
but will prevent any other connection from being accepted for the same quadruplet of
"source address, source port, destination address, destination port".
The solution is to set the socket option in the program with
setsockopt
like this:
setsockopt(socket,SOL_SOCKET,SO_REUSEADDR ... )
Ah, I see, that makes sense. Problem seems to have stopped occuring, thank you very much.
– Captain Trojan
6 hours ago
add a comment |
You are probably re-starting your program too fast, or the program is not closing
the socket.
Even after the socket is closed, Linux keeps the connection in limbo for
some time,
but will prevent any other connection from being accepted for the same quadruplet of
"source address, source port, destination address, destination port".
The solution is to set the socket option in the program with
setsockopt
like this:
setsockopt(socket,SOL_SOCKET,SO_REUSEADDR ... )
You are probably re-starting your program too fast, or the program is not closing
the socket.
Even after the socket is closed, Linux keeps the connection in limbo for
some time,
but will prevent any other connection from being accepted for the same quadruplet of
"source address, source port, destination address, destination port".
The solution is to set the socket option in the program with
setsockopt
like this:
setsockopt(socket,SOL_SOCKET,SO_REUSEADDR ... )
edited 6 hours ago
answered 7 hours ago
harrymcharrymc
281k16 gold badges295 silver badges613 bronze badges
281k16 gold badges295 silver badges613 bronze badges
Ah, I see, that makes sense. Problem seems to have stopped occuring, thank you very much.
– Captain Trojan
6 hours ago
add a comment |
Ah, I see, that makes sense. Problem seems to have stopped occuring, thank you very much.
– Captain Trojan
6 hours ago
Ah, I see, that makes sense. Problem seems to have stopped occuring, thank you very much.
– Captain Trojan
6 hours ago
Ah, I see, that makes sense. Problem seems to have stopped occuring, thank you very much.
– Captain Trojan
6 hours ago
add a comment |
Captain Trojan is a new contributor. Be nice, and check out our Code of Conduct.
Captain Trojan is a new contributor. Be nice, and check out our Code of Conduct.
Captain Trojan is a new contributor. Be nice, and check out our Code of Conduct.
Captain Trojan is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1475140%2fhow-does-the-os-tell-whether-an-address-is-already-in-use%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Unless using RAW sockets, the OS handles TCP. Did you look for connections in any state after the program failed to restart?
– Daniel B
8 hours ago
I checked the port with netstat, lsof, ss and fuser.
– Captain Trojan
6 hours ago