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;








2















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










share|improve this question









New contributor



Captain Trojan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • 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

















2















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










share|improve this question









New contributor



Captain Trojan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • 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













2












2








2








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










share|improve this question









New contributor



Captain Trojan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor



Captain Trojan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



Captain Trojan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 1 hour ago









MarianD

1,7551 gold badge9 silver badges19 bronze badges




1,7551 gold badge9 silver badges19 bronze badges






New contributor



Captain Trojan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 8 hours ago









Captain TrojanCaptain Trojan

133 bronze badges




133 bronze badges




New contributor



Captain Trojan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Captain Trojan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

















  • 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











  • 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










1 Answer
1






active

oldest

votes


















3















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 ... )





share|improve this answer



























  • Ah, I see, that makes sense. Problem seems to have stopped occuring, thank you very much.

    – Captain Trojan
    6 hours ago













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.









draft saved

draft discarded


















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









3















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 ... )





share|improve this answer



























  • Ah, I see, that makes sense. Problem seems to have stopped occuring, thank you very much.

    – Captain Trojan
    6 hours ago















3















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 ... )





share|improve this answer



























  • Ah, I see, that makes sense. Problem seems to have stopped occuring, thank you very much.

    – Captain Trojan
    6 hours ago













3














3










3









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 ... )





share|improve this answer















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 ... )






share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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










Captain Trojan is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單