Showing posts with label networking in java. Show all posts
Showing posts with label networking in java. Show all posts

March 22, 2016

How to get the list of users in network using java

How to get the list of computer users in the network




//List of users in the network

import java.io.*;

public class NetworkUsers
    {
static String all;
     public static void main(String[] args)
         {try {
        // Execute command
       
        Process child = Runtime.getRuntime().exec("net view");
        // Get the input stream and read from it
        InputStream in = child.getInputStream();
        int c;
        while ((c = in.read()) != -1)
        {
        char e=(char)c;
        System.out.println(e);
        //process((char)c);
        }
        in.close();
        } catch (IOException e) { }     }

private static void process(char c) {
// TODO Auto-generated method stub
System.out.print(c);
   //all  =String.valueOf(c) +all;
  // System.out.println(all);
}


         }

Program explanation

Inputstream implies that the program is getting input as a stream of bytes

Similar posts


How to get system details through a bat file



http://javabelazy.blogspot.in/

October 23, 2012

Java client server socket program example

Java networking program to get client ip address in server.


Description : The client tries to establish a connection to server having ip address 127.0.0.1 through port 6363. The socket class is used to establish connection . The server always listen to port 6363 for request from the clients. Once a request reach the server through that port, it establish a connection with that particular client. Multiple clients can connect to server, since i used thread in server.

March 17, 2012

Audio chatting example in java

Audio chatting example in java

The program show a small demonstration of how Audio chat works in java. Click on the link to get the code. Two or more user can audio chat with the application. The program is developed using networking and java packages.
 

Program


Please try audio chatting program... dont forget to post your feed back.

did you ever tried two way chatting using java code. Here we use socket communication, thread for this program. click the below link to download the code. javablzy

Thanking you....


you can mail me to belazy1987atgmaildotcom.

March 08, 2012

how to detect broadcast ip in java


how to detect broadcast ip in java

 How to detect Denial of Service attack

The project need jpcap.

import jpcap.*;
import jpcap.packet.ARPPacket;
import jpcap.packet.Packet;

class Tcpdump implements PacketReceiver {
public void receivePacket(Packet packet) {
if (packet instanceof ARPPacket) {
System.out.println(packet);
ARPPacket arp=(ARPPacket)packet;
// System.out.println(arp.hardtype=ARPPacket.HARDTYPE_ETHER);
// System.out.println(arp.prototype=ARPPacket.PROTOTYPE_IP);
// System.out.println(arp.prototype=ARPPacket.PROTOTYPE_IP);
// System.out.println(arp.operation=ARPPacket.ARP_REQUEST);
System.out.println("sender hardware address ----->" +arp.getSenderHardwareAddress());
System.out.println("Sender protocol address ----->"+arp.getSenderProtocolAddress());
System.out.println("target hardware address ----->"+arp.getTargetHardwareAddress());
System.out.println("target protocol address ----->"+arp.getTargetProtocolAddress());
System.out.println(" arp reply (short) ----->"+ arp.ARP_REPLY);
System.out.println(" arp request (short) ----->"+arp.ARP_REQUEST);
// System.out.println(" arp caplen (int) ----->"+arp.caplen);
// System.out.println(" arp hardtype (short) ----->"+arp.hardtype);
// System.out.println(" arp hlen (short) ------>"+arp.hlen);
// System.out.println(" arp packetlength (int) ------>"+arp.len);
// System.out.println(" arp operation (short) ----->"+arp.operation);
// System.out.println(" arp plen (short) ------>"+arp.plen);
// System.out.println(" arp prototype (short) ------>"+arp.prototype);
// System.out.println(" arp second (long) ------>"+arp.sec);
// System.out.println(" arp usec (long) ------>"+arp.usec);
// System.out.println(" arp hashcode (int) ------>"+arp.hashCode());
// System.out.println(" arp to string ------>"+ arp.toString());
// System.out.println(" arp hardtype ether(short) ------>"+arp.HARDTYPE_ETHER);
// System.out.println(" arp frame relay (short) ------>"+arp.HARDTYPE_FRAMERELAY);
// System.out.println(" arp hardtype ieee802(short) ---->"+arp.HARDTYPE_IEEE802);
// System.out.println(" arp inv reply (short)----->"+arp.INV_REPLY);
// System.out.println(" arp inv request (short)----->"+arp.INV_REQUEST);
// System.out.println(" arp prototype ip (short) ---->"+arp.PROTOTYPE_IP);
// System.out.println(" arp rarp reply (short)----->"+arp.RARP_REPLY);
// System.out.println(" arp rarp request (short)----->"+ arp.RARP_REQUEST);
// System.out.println(" arp data (byte[])---->"+arp.data);
// System.out.println(" arp datalink ( datalink)----->"+arp.datalink);
// System.out.println(" arp header (byte[]) ----->"+arp.header);
// System.out.println(" arp sender hardaddress (byte[])---->"+arp.sender_hardaddr);
// System.out.println(" arp sender proto address (byte[]) ---->"+arp.sender_protoaddr);
// System.out.println(" arp target hard address (byte[])---->"+arp.target_hardaddr);
// System.out.println(" arp target proto address (byte[])----->"+arp.target_protoaddr);
// System.out.println(" arp get class (class) ----->"+arp.getClass());
// System.out.println(" arp end of file ---->"+arp.EOF);
System.out.println(" ******************************************************* ");
String s=arp.getSenderProtocolAddress().toString();
System.out.println("string" +s);
if(s.endsWith("1"))
{
int l=s.length();
String sub=s.substring(1,l);
System.out.println(" sub string(ipaddr)"+sub);
}

System.out.println(" ******************************************************* ");



// arp.hlen=6;
// arp.plen=4;

}
}

public static void main(String[] args) throws Exception {
NetworkInterface[] devices = JpcapCaptor.getDeviceList();
// if(args.length<1){
// System.out.println("usage: java Tcpdump

Facebook comments