C and Network

A

Aleramo

I want to know if it's possible writing in the C-Language a program
that could:
1) identify the servers and computers in a local network, and knowing
the computers i could access with my identity;
2) give me the possibility to choose one computer i can access, to
have the list of directories and files on C (for Windows) or in the
Home (for Linux).

I hope it's possible writing it with some functions in a library,
because i like C and i don't want to change it with another language.

Bye bye Marco.
 
L

Lew Pitcher

I want to know if it's possible writing in the C-Language a program
that could:
1) identify the servers and computers in a local network, and knowing
the computers i could access with my identity;

Not with Standard C. You'd need networking-specific extensions to do
that.
For details, you'll have to ask in a group that deals with the
development of networking code on your platform.
2) give me the possibility to choose one computer i can access, to
have the list of directories and files on C (for Windows) or in the
Home (for Linux).

Not with Standard C. You'd need networking-specific extensions to do
that.
For details, you'll have to ask in a group that deals with the
development of networking code on your platform. I suggest
comp.os.linux.networking and/or comp.os.linux.development.apps (for
Linux) and one of the comp.os.ms-windows.* newsgroups (for Windows)
I hope it's possible writing it with some functions in a library,
because i like C and i don't want to change it with another language.

You'll likely find a library somewhere. But, unfortunately, not here.
Sorry
 
D

Doug

I want to know if it's possible writing in the C-Language a program
that could:
1) identify the servers and computers in a local network, and knowing
the computers i could access with my identity;
2) give me the possibility to choose one computer i can access, to
have the list of directories and files on C (for Windows) or in the
Home (for Linux).

I hope it's possible writing it with some functions in a library,
because i like C and i don't want to change it with another language.

Bye bye Marco.

Hi Marco,

You'll soon be receiving lots of "we can't help you here" responses.
Sorry about that. You can indeed do what you require in C, though not
standard C. So I'm supposed to point you to other newsgroups where
you can ask more directed questions.

I'll try to give you some pointers, though. I won't bother pointing
out other newsgroups directly - I'm sure you can find them easily
enough. If you can write C, which it sounds like you can, then that
won't be a problem.

If this is a fun, personal, project, then I'd do this with a server-
client type approach. You'll need to use some non-standard-C stuff to
get the job done:
- you'll want a client and a server process. For communication over a
typical network you'll need to know about "sockets". Google and read
up on it over several cases of beer; expect it to take a while.
You'll also need this for your network discovery - finding the other
machines you care about.
- on the servers, you'll need to know how to access the local
filesystem. Google readdir, I'm sure it'll point you to the
equivalents on other platforms
- try and write the code so that the pieces involved in the above are
isolated and can be easily substituted depending on your OS. This
will give you some element of portability.

If this is not for fun, if you just need to get something running:
- if it doesn't need to be homegrown, maybe samba would work for the
platforms you care about. There are other platform specific utilities
(like network shares on windows) that can do the job. At the client
end, the details could be hidden behind a simple CLI script.
- on some OSes (windows is the only one I know about for sure) there
are calls I believe you can make to ask the remote computer to tell
you what you want to know. I'm afraid I don't know much about it,
though. Newsgroups might help here.

Again, this is all very OT here. I'm going to duck now.

Hope that helps,
Doug
 
W

Walter Roberson

I want to know if it's possible writing in the C-Language a program
that could:
1) identify the servers and computers in a local network, and knowing
the computers i could access with my identity;

In addition to Lew's correct comments about networking being OS
specific, the answer to (1) is NO: in the general case, it
is not possible to identify the servers and computers on a local network.
No matter what program you run, there is always the possibility that
the remote systems are deliberately refusing to reply to your
computer in particular, or that the remote systems are deliberately
refusing to reply to anyone who doesn't present the proper secret
authentication sequence. There is no guaranteed method to provoke
a remote computer to reveal its existance if it doesn't want to
talk to you.

[getting OT]

*If* you know that the computers/servers are in particular address
ranges, then the general way to find out which computers you could
access with your identity, is to try each address in sequence,
attempting an access with your identity on each; the ones that
respond with positive confirmation are the ones you can access,
the ones that do not respond with positive confirmation either
don't exist or don't allow you access with your identity.

If you do not know the address ranges of the computers/servers
in your local network... well, you could try each of
the roughly 3.7 billion valid IPv4 addresses in turn, but it would
take a long time and your network administrator is unlikely
to be pleased with you (!!!)


Some systems -advertise- their existance and potential availability for
certain kind of accesses, and it is *relatively* easy to write
an OS-specific program to pay attention to those advertisements.
You generally wouldn't bother, though -- you'd generally just use
a program that someone's already written for the purpose. And
knowing which systems -advertise- access potential is quite a different
question than knowing which non-advertising systems would let you
have access.
 
W

Walter Roberson

Hi Marco,
You'll soon be receiving lots of "we can't help you here" responses.
Sorry about that. You can indeed do what you require in C, though not
standard C.

No you cannot. It is not POSSIBLE in the general case. Think
firewalls. You cannot identify the computers on a local network
if they refuse to talk to you or to any system that you have
access to.

To emphasize this further: if I'm on Marco's network, and I
turn off networking on my computer, then my computer is still
in the local network, but it is impossible to reach, so it cannot
be identified as being present, not by any means short of physical
enumeration.
 
C

CBFalconer

Doug said:
You'll soon be receiving lots of "we can't help you here" responses.
Sorry about that. You can indeed do what you require in C, though not
standard C. So I'm supposed to point you to other newsgroups where
you can ask more directed questions.

I'll try to give you some pointers, though. I won't bother pointing
out other newsgroups directly - I'm sure you can find them easily
enough. If you can write C, which it sounds like you can, then that
won't be a problem.

Don't do this. Experts on the advice you give are not
(necessarily) present here, so mistakes will not get corrected.
You should limit your advice to pointing out suitable newsgroups.
 
D

Doug

No you cannot. It is not POSSIBLE in the general case. Think
firewalls. You cannot identify the computers on a local network
if they refuse to talk to you or to any system that you have
access to.

<snip>

Agreed, there's no way to do it in the general case. I was assuming
that the OP had control over his own local network. I assume he's not
an idiot and knows this too. He talked about identity, so I assume he
at least expects authentication and authorisation to play a part.

But you're right, he should just give up.

Doug
 
A

Aleramo

Hi Marco,

You'll soon be receiving lots of "we can't help you here" responses.
Sorry about that. You can indeed do what you require in C, though not
standard C. So I'm supposed to point you to other newsgroups where
you can ask more directed questions.

I'll try to give you some pointers, though. I won't bother pointing
out other newsgroups directly - I'm sure you can find them easily
enough. If you can write C, which it sounds like you can, then that
won't be a problem.

If this is a fun, personal, project, then I'd do this with a server-
client type approach. You'll need to use some non-standard-C stuff to
get the job done:
- you'll want a client and a server process. For communication over a
typical network you'll need to know about "sockets". Google and read
up on it over several cases of beer; expect it to take a while.
You'll also need this for your network discovery - finding the other
machines you care about.
- on the servers, you'll need to know how to access the local
filesystem. Google readdir, I'm sure it'll point you to the
equivalents on other platforms
- try and write the code so that the pieces involved in the above are
isolated and can be easily substituted depending on your OS. This
will give you some element of portability.

If this is not for fun, if you just need to get something running:
- if it doesn't need to be homegrown, maybe samba would work for the
platforms you care about. There are other platform specific utilities
(like network shares on windows) that can do the job. At the client
end, the details could be hidden behind a simple CLI script.
- on some OSes (windows is the only one I know about for sure) there
are calls I believe you can make to ask the remote computer to tell
you what you want to know. I'm afraid I don't know much about it,
though. Newsgroups might help here.

Again, this is all very OT here. I'm going to duck now.

Hope that helps,
Doug

My boss gave me this problem to solve with the safety it could be
possible. I had some doubts but he was so safe that i preferred
trying. He was so safe he told me i could solve it for Windows but i
had understood there are some chances for Linux and no for Win.
I think i have to change language, i think at C# he assured me it can
do it. I'll try.

Thank you to everybody :)
 
S

SM Ryan

# >
# > > I want to know if it's possible writing in the C-Language a program
# > > that could:
# > > 1) identify the servers and computers in a local network, and knowing
# > > the computers i could access with my identity;
# > > 2) give me the possibility to choose one computer i can access, to
# > > have the list of directories and files on C (for Windows) or in the
# > > Home (for Linux).

# > - you'll want a client and a server process. For communication over a
# > typical network you'll need to know about "sockets". Google and read
# > up on it over several cases of beer; expect it to take a while.
# > You'll also need this for your network discovery - finding the other
# > machines you care about.

# My boss gave me this problem to solve with the safety it could be
# possible. I had some doubts but he was so safe that i preferred
# trying. He was so safe he told me i could solve it for Windows but i
# had understood there are some chances for Linux and no for Win.
# I think i have to change language, i think at C# he assured me it can
# do it. I'll try.

Also sockets generally assume they're talking between specific,
known machines. To communicate to anybody on a network without
knowing who they are beforehand might depend on broadcasts or
other protocols such as ethernet. I think DHCP or Apple's Bonjour
are supposed to do this; perhaps those could give you some ideas.

I don't know if C# is implemented on Linux.
 
R

Richard Bos

Aleramo said:
My boss gave me this problem to solve with the safety it could be
possible. I had some doubts but he was so safe that i preferred
^^^^
This is not the translation of "sicuro" you are looking for.
trying. He was so safe he told me i could solve it for Windows but i
had understood there are some chances for Linux and no for Win.

He doesn't know what he's talking about.

It _is_ generally possible, on both Windows and Unixoids, _if_ you can
assume a friendly network. However, both these solutions require non-ISO
extensions, and different ones, at that. As for "changes for Linux, no
for Windows" - if you assume POSIX as the most usual extension standard
for C, it's exactly the other way 'round.
I think i have to change language, i think at C#

*Shudder* Why not go the whole hog and switch to Visual Basic? That way
at least you'll _know_ that it won't ever work properly on anything but
specific versions of MS Windows.

Richard
 
C

Chris Hills

CBFalconer said:
Don't do this. Experts on the advice you give are not
(necessarily) present here,

They may well be and you have no idea what expertise most of us have.
so mistakes will not get corrected.
No more than on any other NG.
You should limit your advice to pointing out suitable newsgroups.
This is one of them.
 
R

Richard Heathfield

Chris Hills said:
They may well be and you have no idea what expertise most of us have.

That's the problem. The best newsgroup to ask questions about <foo> is a
newsgroup where the regular contributors are known to have expertise
about <foo>. For a network programming question, that would be a
network programming newsgroup. This is a great newsgroup for C
questions, but a lousy group for other kinds of questions.
No more than on any other NG.

Not so. On a network programming newsgroup, the local experts are far
more likely to spot, and correct, wrongful advice about network
programming than is the case here in comp.lang.c. This is common sense.
This is one of them.

Not for the OP's question, it isn't.
 
R

Richard

Richard Heathfield said:
Chris Hills said:


That's the problem. The best newsgroup to ask questions about <foo> is a
newsgroup where the regular contributors are known to have expertise
about <foo>. For a network programming question, that would be a
network programming newsgroup. This is a great newsgroup for C
questions, but a lousy group for other kinds of questions.


Not so. On a network programming newsgroup, the local experts are far
more likely to spot, and correct, wrongful advice about network
programming than is the case here in comp.lang.c. This is common sense.


Not for the OP's question, it isn't.

If someone helps him , then it is.

Jesus H Christ. Give it a rest. Let "OT" threads die of their own
accord. Change the bloody record already. There are more net nanny posts
from self appointed Godz own in this group than in the rest of usenet
together.
 
D

Doug

CBFalconer said:
Doug wrote:


Don't do this. Experts on the advice you give are not
(necessarily) present here, so mistakes will not get corrected.
You should limit your advice to pointing out suitable newsgroups.

I think that's pretty much what I did. Except that instead of blindly
giving him the name or names of some newsgroups, I gave him some
background info so he could find them himself. Or find some non-
newsgroup help, like a book. Or realise there are existing tools
which already do it ("what is it you're really trying to do?").

I understand your sentiment, but given the lack of any detail in my
post, I find it hard to see how it applies. It fits into the self-
aggrandising, net-nanny category.

I'm sure you'll disagree, and I'm sorry about that, but there you go.

Now, I really do have better things to do than take part in one of
these stupid net-nanny threads. Which is what this, and just about
every other post in clc, has become.

Doug
 
R

Richard Heathfield

Doug said:

Now, I really do have better things to do than take part in one of
these stupid net-nanny threads.

So do we all.
Which is what this, and just about every other post in clc, has
become.

If people posted in the right newsgroup in the first place, this would
not be the case. For my own part, I'd rather be discussing C than
topicality. Wouldn't you?
 
C

Chris Hills

Richard <[email protected]> said:
If someone helps him , then it is.

Jesus H Christ. Give it a rest. Let "OT" threads die of their own
accord. Change the bloody record already. There are more net nanny posts
from self appointed Godz own in this group than in the rest of usenet
together.

The OT net nannies are generating more OT traffic and noise here than
anything else.

If they shut up there would be far fewer OT posts. More to the point
some of the "OT" posters would come back and inject some more life and
people into this NG with more ON topic posts.
 
R

Richard Heathfield

Chris Hills said:

The OT net nannies are generating more OT traffic and noise here than
anything else.

No, the noise is from people who don't understand what the topic is, and
you appear to be one of them. Those you disparagingly call "net
nannies" are just trying to stop the group following clc++ into a chaos
from which that group took years to emerge. You know all this, and yet
you persist in trying to damage the group.
If they shut up there would be far fewer OT posts.

No, there would be far more, and eventually we'd be swamped by them, and
there'd be nowhere left to discuss standard C.
More to the point
some of the "OT" posters would come back and inject some more life
and people into this NG with more ON topic posts.

I disagree. OT posters are not known for posting on-topic posts.
 
R

Richard

Richard Heathfield said:
Doug said:



So do we all.


If people posted in the right newsgroup in the first place, this would
not be the case. For my own part, I'd rather be discussing C than
topicality. Wouldn't you?

Then do it. You really don't get it do you?
 
R

Richard

Richard Heathfield said:
Chris Hills said:



No, the noise is from people who don't understand what the topic is, and
you appear to be one of them. Those you disparagingly call "net

Heathfield simply can't help himself. His self opinion is of legendary
proportions.
nannies" are just trying to stop the group following clc++ into a chaos
from which that group took years to emerge. You know all this, and yet
you persist in trying to damage the group.

He is a knowledgeable and helpful poster. Someone YOU could learn
from. Instead you persist in wrapping the simplest things in high level
mumbo jumbo more designed to demonstrate your own cleverness than to
help the nOOb.
No, there would be far more, and eventually we'd be swamped by them, and
there'd be nowhere left to discuss standard C.

Rubbish. Just ignore them.

You see it's very simple : if a post is OT and then there are 5 "OT
replies" then there are 6 OT posts. Get it yet?
I disagree. OT posters are not known for posting on-topic posts.

Depends how Off Topic.
 
W

Walter Roberson

He doesn't know what he's talking about.
It _is_ generally possible, on both Windows and Unixoids, _if_ you can
assume a friendly network.

[OT]

A *very* friendly network. An *extrodinarily* friendly network.

Richard, have you ever actually -been- a network administrator
on a non-trivial network (say, more than 256 hosts) ? I have,
and I was pretty good at it -- but there were times when it would
take weeks or months to track down certain devices that would appear
for short times and then disappear, even though we were using
"fully managed" network infrastructure. See for example,

http://groups.google.ca/group/comp.dcom.lans.ethernet/msg/af01a32555eb5660


The point being that unless you have full complete taps on all of your
switches, you -cannot- identify all the "servers and computers" on a
network (the first thing requested by the original poster) -- and even
with full taps, you might not be able to locate some devices that seem
to appear. With less than full taps, using software monitoring
techniques such as SNMP monitoring to examine the switch and routing
tables, you simply will not be able to find all of your computers,
even ones that talk occasionally.

I'm not just "being contrary": I worked -hard- in networking for a
decade. Identifying the computers on a network is, in practice,
a difficult job, requiring a lot of analysis and cross-correlation --
and requiring a deep appreciation for the unfortunate truth that,
"Switches Lie!"


The OP's task would be considerably easier if the OP restricted themselves
to computers that announce themselves on the local network,
such as via NETBIOS; for that kind of effort, probably looking
at the samba functionality (as mentioned by a previous poster)
would be fruitful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top