Reading subtext from interview questions
Companies are free to use whatever kinds of knowledge and skill filters they would like to asses people before hiring them. An investment bank could ask you to sing a Michael Jackson song in your interview if that's what they really felt would tell them what they needed to know about you. So on one hand, there's not much use in trying to read too much into it.
If you present yourself honestly and clearly state the limits of your experience and knowledge, then the company can evaluate whether you'll be a good fit. In your example, perhaps it is the case that the position required a lot of network programming expertise from the very first day on the job. In that case, the company needs to know if you can answer those sorts of questions on the spot. If not, then it's likely that neither you nor the company feel it is a good fit.
On the other hand, interviews are also about detecting limitations in an future employee. No one knows everything, so sometimes an interviewer will intentionally make the questions very hard, or will find increasingly obscure topics, until they finally find things that a candidate cannot answer. This is not an attempt to embarrass or criticize the candidate -- it's merely important to know the limitations of people you hire just the same as it is important to know the areas in which they excel.
As a result, sometimes you will get lots of questions that seem to come from nowhere and which you cannot answer very well. This may not always imply that the job requires you to know that material -- it might just be a way for the hiring manager to know exactly what role you could fit into on the team.
Given all of this, the best course of action is to ask questions yourself. If you speak with a recruiter or an HR contact about a job prior to a technical assessment, try to ask lots of questions about the responsibilities of the role. If you have very specific preferences about the kinds of work that you will or will not accept, just politely describe them. You'll save yourself a lot of time this way. Most technical interviewers will be happy to describe the technical needs for the position and help explain why the particular interview questions they have asked are useful.
Learn a skill just for an interview
This is more of an opinion-focused question. My advice: if it doesn't cost you much (time, money, stress) to learn a new skill, then do it. The fact that it is showing up in lots of interviews means that it is likely to be valuable. Don't pay too much attention to your very specific preferences for what you "desire" to learn. In the future, who knows whether you will have wanted that skill or not. And learning at least a little bit about it now could pay big dividends later.
Obviously you must make trade-offs. You can't learn every skill, some skills are costly to learn, some skills have more questionable value than others, and you have to budget your time for other activities besides skill acquisition. No one can tell you how to value the different choice options in that context, but my opinion is that you should err more on the side of learning as many skills as you can. And sometimes picking a skill that represents every thing you think you would hate doing for a job and then forcing yourself to become good at it -- that can be a very enlightening experience.