public void run() {
    if (clientSocket == null) {
      return;
    }

    PrintStream out = null;

    Utilities.printMsg("creating output stream");

    try {
      out = new PrintStream(clientSocket.getOutputStream());
    } catch (IOException e) {
      System.err.println("Error binding output to socket, " + e);
      System.exit(1);
    }

    Utilities.printMsg("writing current date");

    Date d = new Date();
    out.println(d);

    try {
      out.close();
      clientSocket.close();
    } catch (IOException e) {
    }
  }
  public String toString() {
    String s = "";
    s += this.getPacket().toString();
    s += "IP VersionIHL: " + this.versionIhl + "\n";
    s += "IP TOS: " + this.tos + "\n";
    s += "IP Length: " + this.len + "\n";
    s += "IP ID: " + this.id + "\n";
    s += "IP Flag/Frag: " + this.flagFrag + "\n";
    s += "IP TTL: " + this.ttl + "\n";
    s += "IP Protocol: " + this.proto + "\n";
    s += "IP Chksum: " + this.checksum + "\n";

    s += "IP Source: " + Utilities.longToIPAddress(this.ipSource) + "\n";
    s += "IP Destination: " + Utilities.longToIPAddress(this.ipDestination) + "\n";

    return s;
  }
Example #3
0
 /** Creates a network scan over the specified port */
 public NetScan(TransactionId tid, TupleDesc td, int port) {
   try {
     this.tid = tid;
     this.td = td;
     this.port = port;
     serverSocket = Utilities.createServerSocket(port);
   } catch (IOException ioe) {
     ioe.printStackTrace();
     closeConnection();
     throw new RuntimeException(ioe);
   }
 }
Example #4
0
  @RequestMapping(
      value = "/home",
      method = {RequestMethod.GET, RequestMethod.POST})
  public String getCity(HttpServletRequest request, ModelMap model) {

    try {
      List<City> cityList = cityService.getCity();
      utilities.setSuccessResponse(response, cityList);
    } catch (Exception ex) {
      logger.error("getCity :" + ex.getMessage());
    }
    model.addAttribute("model", response);
    return "home";
  }
Example #5
0
  @RequestMapping(
      value = "/getCityApi",
      method = {RequestMethod.GET, RequestMethod.POST})
  public String getCityApi(
      HttpServletRequest request,
      @RequestParam(value = "locationname") String locationname,
      ModelMap model) {

    Map<Object, Object> map = new HashMap<Object, Object>();
    JSONArray jSONArray = new JSONArray();
    try {
      String status = "active";
      List<City> cityList = cityService.getCityApi(locationname, status);
      if (cityList != null && cityList.size() > 0) {
        for (int i = 0; i < cityList.size(); i++) {
          City city = (City) cityList.get(i);
          String cityName = (String) city.getCity();
          String stateName = (String) city.getState();

          int ID = (Integer) (city.getId());
          JSONObject jSONObject = new JSONObject();

          jSONObject.put("id", ID);
          jSONObject.put("text", cityName);
          jSONArray.put(jSONObject);
        }
        utilities.setSuccessResponse(response, jSONArray.toString());
      } else {
        throw new ConstException(ConstException.ERR_CODE_NO_DATA, ConstException.ERR_MSG_NO_DATA);
      }
    } catch (Exception ex) {
      logger.error("getCity :" + ex.getMessage());
      utilities.setErrResponse(ex, response);
    }
    model.addAttribute("model", jSONArray.toString());
    return "home";
  }
Example #6
0
 /** Opens this net scan. */
 public void open() throws DbException {
   try {
     if (socket == null) {
       Debug.println("NetScan accepting @ :" + port);
       socket = Utilities.accept(serverSocket);
       Debug.println("NetScan accepted, creating input stream...");
       in = new DataInputStream(socket.getInputStream());
       Debug.println("NetScan opened");
     }
   } catch (IOException ioe) {
     ioe.printStackTrace();
     closeConnection();
     throw new DbException(ioe);
   }
 }