-19

I had a C socket API question on how to "connect to an IP address that exists in [two subnets]" and how to choose which one of them to connect to.
I quickly received a helpful (and correct) answer stating that the OS uses a routing table and that this most likely cannot be done programmatically and depends on OS settings.

However, afterward, it was quickly shut down because people could "see absolutely no indication that this question is programming-related", despite the fact that the question had been about how to achieve a clear task programmatically, and that I had already received an answer to this effect, stating that such an API unfortunately does not exist.

Now, obviously, I had no idea beforehand whether this can be done programmatically, or I would have already known the answer to my question.

But people are saying that means the question is off-topic and not even programming-related?
(Presumably if there was such an API, it would render the exact same question on-topic?)

Does this mean users are expected to know the answer to their question already in order to know whether their question is on-topic?
Can someone explain this? It seems like a pretty clear-cut socket programming question to me.

Edit:

I guess I should have asked this explicitly since no one has addressed this so far, but if you don't think the question belonged on Stack Overflow, then where do you think the appropriate site would have been?

11
  • It should be on superuser.com if it isn't directly programming related
    – Papershine
    Aug 27, 2017 at 13:07
  • Any mods care to chime in? I still don't understand the mod comment that "Saying that it's not possible to do it via code is essentially the whole point." Is the positivity or negativity of the answer supposed to affect the on-topic-ness of the question on this site, or no?
    – user541686
    Aug 27, 2017 at 13:32
  • I assume they didn't comment in their capacity as mod ... let's not go down the road where a few mods determine what is on- or off-topic here and we all follow.
    – rene
    Aug 27, 2017 at 13:56
  • @rene: Cody Gray definitely commented in his capacity as mod (even if he somehow didn't intend to, which is unlikely). He cast the final close vote right when he came and immediately wrote his comment, and that wasn't even the 5th vote cast. If he's going to mod-hammer questions into closing then I would very much like to understand his reasoning.
    – user541686
    Aug 27, 2017 at 13:59
  • 1
    @Mehrdad: I see no indication that Cody's comment would be any different had he not been a moderator. His vote was the 4rth, I would happily have added a 5th vote (again, moderator or not). Your question was off-topic, a moderator only helped speed along the closure.
    – Martijn Pieters Mod
    Aug 27, 2017 at 14:14
  • @MartijnPieters: You don't have to word any things differently when you're saying something in a different capacity. He was clearly explaining his decision to close the question; that to me is as clear an indication as any that he was writing this as a moderator. I'm honestly not sure this is even germane to the issue though; I'm surprised it was brought up at all.
    – user541686
    Aug 27, 2017 at 14:18
  • 3
    You are arguing in circles. Cody gave his reasons to cast a close vote. Those reasons are still the same with and without a binding vote. There were 3 other votes, others told you the same thing.
    – Martijn Pieters Mod
    Aug 27, 2017 at 14:20
  • @MartijnPieters: Could you address this/this (which is also in my question above)? It's actually quite the opposite of what others have said.
    – user541686
    Aug 27, 2017 at 14:21
  • @MartijnPieters: Still waiting for a response to this^
    – user541686
    Aug 28, 2017 at 17:17
  • 1
    @Mehrdad: and I'm not interested in being drawn into a long drawn-out discussion.
    – Martijn Pieters Mod
    Aug 28, 2017 at 17:19
  • @MartijnPieters: I'm not asking for a long drawn-out discussion, I'm literally asking if the answer should affect whether the question is on-topic as Cody had said. That should be yes/no.
    – user541686
    Aug 28, 2017 at 17:20

2 Answers 2

10

I believe, there are 2 questions here:

  1. In general, are questions, where the OP does not know beforehand if they are programming related, off-topic in case they turn out to be not programming related?

    I think the answer is: yes, they are off topic because they are not related to programming. The fact that the OP is not aware must not make it on-topic, otherwise any OP could claim ignorance when asking non-programming related questions.

  2. Specifically, is your question programming related?

    Now, I think this is a bit more tricky. Because of the way you asked the question, I agree with those, who closed it. Why? Because if you have multiple network adapters, then choosing where to route the traffic is done by configuring the OS or specific routing softwares. You do not really expect to do this from a common application, you would expect the OS to be configured to route the traffic. Moreover, such routing has really nothing to do with sockets or a specific programming language, but these have already been explained in comments below the question.

    Were your question worded something like "how do I programmatically set or determine which network adapter is used for a certain IP address under operating system X?", then I believe, your question would not have been closed as not programming related. Nevertheless, I still expect this modified question to be downvoted when you mention that the two networks have the same IP address range. Also, I would expect lots of comments asking for why you want to do this programmatically, when the OS can take care of this.

    Btw, obviously you can change adapter priority and routing rules under most operating systems in a programmatic way. But the exact way is entirely OS specific.

15
  • +1 thanks! It's nice to get a third-party opinion. Question about your answer though: what about the fact that I had tagged the question as C and sockets, and I was asking how to connect to an IP address? Do those actually indicate some kind of OS/networking configuration question to you, or do they indicate a question about how to connect to a particular host via sockets in C?
    – user541686
    Aug 27, 2017 at 12:32
  • As I wrote, I would not expect an sw to handle these things programmatically and the the tags you chose are irrelevant to the question. (Yeah, I know, it is hard to choose the appropriate tags if you do not know the answer.) Therefore, it is difficult to interpret your question as it is worded now as sg programming related.
    – Shadow
    Aug 27, 2017 at 12:37
  • If you reworded the question to make it clear 1) you want to programmatically route traffic 2) what operating system you use 3) how you can distinguish which network adapter to use if the IP addresses are the same, then I'm happy to cast a reopen vote. Obviously, you would have to un-accept the non-programming answer. However, I would still expect downvotes as the starting point (2 networks with same IP address range) seem to be the root cause of the issue in the first place.
    – Shadow
    Aug 27, 2017 at 12:47
  • Thanks for the suggestion :) it's nice to finally see a concrete and actionable one. I've updated the question as you asked. I haven't un-accepted the answer though since it is a programming answer -- it simply says there is no programmatic solution.
    – user541686
    Aug 27, 2017 at 13:03
  • Ouch, I think you made your question too broad by not specifying the OS (listing 3 completely different ones is pretty much the same as not specifying any) and not specifying how to distinguish between the 2 networks
    – Shadow
    Aug 27, 2017 at 13:24
  • Wait but why? I did specify 3 OSes (or as many as allow this) and I said I'm fine with any solution for distinguishing them -- whoever has an answer can pick one. I guess I could arbitrarily pick one (e.g. MAC address, index, etc.) but how would that help? It would artificially narrow the solution set when I don't have any such artificial constraints in the problem. Are you saying I should post 9 different questions for each of the 9 combinations of 3 OS x 3 distinction methods? I want to write a program that works on as many OSes as possible, not just the current OS I'm personally running.
    – user541686
    Aug 27, 2017 at 13:26
  • 1
    The answer per OS will be different and lengthy in itself, so combining them into a single answer is difficult. Linux has lots of different distros and there may be differences on distro level as well. Moreover, how many people do you think there are, who know all the OS in such a great detail? As per how to distinguish between the 2 networks - I expect you to tell me. These are your networks, you are the one who is familiar with their details, not us.
    – Shadow
    Aug 27, 2017 at 13:34
  • Okay but I still don't understand, are you saying I should have 3+ questions, one for each platform? And what do you mean these are "your" networks? What makes you think I'm the single user of the program I'm writing? This isn't just for me, I want others to be able to use my program too. If it was just about me I would be saying "me", not "users"!
    – user541686
    Aug 27, 2017 at 13:37
  • 2
    I thought you had a specific problem, whereby you had 2 networks connecting to a specific computer, running a specific OS. This is a type of question that is suitable for SO. If you have a general question, then I'm afraid, it may not be suitable for SO, even if it is programming related.
    – Shadow
    Aug 27, 2017 at 13:41
  • 1
    What? Are you saying the only questions suitable for SO are those programs that programmers are writing for themselves personally? I can't be writing a cross-platform program for several users and asking about that?
    – user541686
    Aug 27, 2017 at 13:43
  • 1
    I've said this before but it seems you missed this: The problem is pretty clear and specific, it's the programming problem of how to communicate with different hosts that have identical IP addresses. But the fact that there are identical IP addresses is not itself the problem under question. You understand this right? The question is not about the network management.
    – user541686
    Aug 27, 2017 at 13:46
  • @Mehrdad no, I have not missed that, just I disagree. Your question is clear, but not specific at all. By expecting the answers to cover all OS and expecting us to suggest a method to distinguish between devices with conflicting IP addresses makes the question too broad and primarily opinion based. SO is no about discussing suggestions.
    – Shadow
    Aug 29, 2017 at 0:04
  • Here's what I don't understand: if I just said artificially said I want to distinguish the adapters "based on an index (0, 1, 2, ...)", would you feel it's somehow better? Even though it's a totally artificial restriction?
    – user541686
    Aug 29, 2017 at 0:12
  • Nope, you would have to provide a lot more details, such as how the indexes are created, maintained, and most importantly, how do you make the IP take notice of this.
    – Shadow
    Aug 29, 2017 at 0:29
  • What about MAC address? (User-provided)
    – user541686
    Aug 29, 2017 at 0:42
6

As one of the close voters: The only indication that this was about the C socket API was that the word connect in the sentence is written in code formatting. I already explained that in the comments of the question.

Even if you get that, the question ask "How can I control what happens in such a case?", not "How can I control what happens programmatically?" which is a huge difference.

For me this question still reads like a network/OS configuration question and not like a programming question.

16
  • 1
    If the accepted answer had given an API (plus maybe an example) for actually doing this would you have still said this is not programming-related?
    – user541686
    Aug 27, 2017 at 11:49
  • 3
    Yes. You should never judge a question by the quality/content of the answers.
    – BDL
    Aug 27, 2017 at 11:52
  • 2
    The question was clearly tagged C and sockets? How come the connect only indication that it is asking to do something using code? That connect was even formatted as code, I don't see any reason to confuse it as normal word connect.
    – taskinoor
    Aug 27, 2017 at 11:53
  • 2
    @BDL: I just don't understand. You really, honestly, genuinely see C and sockets and connect in the question and you think "oh my god, I bet this is an OS network configuration question!"? You really don't think this was a quick misjudgment on your part?
    – user541686
    Aug 27, 2017 at 12:02
  • 1
    And for the record, Cody Gray disagree with you that the content of the answer is irrelevant. To quote him verbatim (emphasis mine), "Saying that it's not possible to do it via code is essentially the whole point." So he would've seen it as quite a different situation if there had been an API for doing this!
    – user541686
    Aug 27, 2017 at 12:04
  • In my opinion: It is still not clear that this is about the linux socket library. sockets is not specific to that library. Could also be connect from winsock or any other library. Even if we leave this point out, the question still doesn't ask for a programmatic solution: If I add an answer explaining how to configure your network interface on Windows to prevent the problem, would you accept it? It would perfectly answer the question since you never ask for Linux or for a code solution.
    – BDL
    Aug 27, 2017 at 12:12
  • 1
    I'm not saying that my opinion is necessarily the correct one, I just wanted to explain why I voted to close the question. If there are other who disagree with me, feel free to reopen/write another answer here.
    – BDL
    Aug 27, 2017 at 12:13
  • 1
    @BDL: "It is still not clear that this is about the linux socket library." Indeed, it never was. It's not about any particular library, it's about the standard socket APIs. When someone asks how to use printf to print an int, do you think they're asking about GLIBC?
    – user541686
    Aug 27, 2017 at 12:14
  • @BDL: As for whether I would accept an answer telling me how to configure my network to prevent the "problem": no, I would not accept it because I'm not asking how to prevent any problem at all. The word "problem" wasn't even in the question because I don't really see this as a problem, I see it as a scenario any grandpa could get into. But if you did post an answer explaining how to contact the two hosts non-programmatically, I might actually accept it because it would probably help me figure out how those programs achieve this internally (I can always disassemble etc.).
    – user541686
    Aug 27, 2017 at 12:16
  • @BDL: And I appreciate that you explained your answer, but surely you realize that it's not helpful without a sound/consistent reason behind it? The goal here is to help me (and others) figure out where to ask each question in the future, after all. So far I have no idea. I've explained why pretty much none of your rationales seem to be consistent with the situation (e.g. above^) but it seems you're searching for a correct reason to justify the vote rather than for a vote to justify the correct reason. =\
    – user541686
    Aug 27, 2017 at 12:27
  • I told you where in my opinion the problem is: 1) Clarify what you are doing and in which setup/library you expect answers 2) Explicitly ask for a programming solution. If you are not willing to make these changes in your question, feel free to wait for someone else who thinks that this questions should be reopened in the current state.
    – BDL
    Aug 27, 2017 at 12:35
  • 5
    It doesn't seem that you are really seeking for input how to improve the question, but instead just try to argue why the five close voters are wrong. I already regret having tried to explain my reasons. It the same situation why a lot of people don't want to leave comments under the question anymore when downvoting or closevoting.
    – BDL
    Aug 27, 2017 at 12:38
  • @BDL: Nah, I already updated the answer in response to Shadow's answer. The trouble I've been having with your reasoning is that it doesn't make any sense to me: you say "Linux" but I never said "Linux"; I never even asked anything OS-specific. You say I need to specify a "library" but I'm not asking about any library, just about the traditional C sockets API. You say the "only" indication that this was a programming question and not an OS/configuration was that I formatted "socket" as socket, which is factually wrong since I also had the C and sockets tags, etc....
    – user541686
    Aug 27, 2017 at 13:12
  • 1
    @BDL: On the other hand, Shadow pointed out 2 very key things: (1) this is something that everyone expects to happen at the OS level, and that is why people don't expect this to be a programming question, and (2) given the above, people assume the tags are out-of-place, not the other way around. This differs critically from your response -- to quote yourself, you said: "If you read that in a review queue, it looks as if you just want to connect to something and use strange formatting", which only implies the close votes were based on a cursory misreading and ignorance of the tags.
    – user541686
    Aug 27, 2017 at 13:23
  • 2
    @Mehrdad I disagree with your conclusion. The close votes are result of not clear wording of the question and inappropriate tags.
    – Shadow
    Aug 27, 2017 at 13:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .