ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am new to network programming,dealing with sockets(bsd)
I want to know what all other ACTIVE systems present on network.how to code??approach is enough please throw ur ideas
my thought: i will act as client & 'connect' to rest of systems
...every other system should work as server and 'accept'my request
if so
i will make a count of active systems present on network
"connect" is a system call in linux which the client side program uses to connect to a known server
"accept" is also a system call but from server side to hear a request from client.
practical implementation of my code:
In hospital every bed has a patient monitoring system and all the systems r in a local network
every system should know what all other systems r present in the network
so this isn't a case of just finding all machines on a network, but all instances of a given tcp service listening on a certain port... wouldn't really know much about that to be honest, not without port scanning, which is pretty crude. better off in the Programming forum really, moving it there now.
my first thought when reading this was port scanner
will you be trying all well known ports.
or a significant few?
You may want to look at the source code for nmap
doing nmap -sP 192.168.0.0/24 for example
will do a ping scan on every machine on the subnet and then print out the available machines.
This obviously uses an icmp echo requestand I gather from eading the man page for nmap it also sends a tcp packet to port 80 using connect() as well.
public static void main(String a[]) throws IOException {
Vector v=new Vector();
Vector sample=new Vector();
Vector count=new Vector();
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the Data : ");
String s=bf.readLine();
// String s="the animal is so big, big animal can run fast so we should take care";
StringTokenizer temp=new StringTokenizer(s," ");
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.