<commit_before>package com.lion.rmtsndcli;

import java.io.*;
import java.net.*;
import java.nio.charset.Charset;

public class Requester{
	Socket requestSocket;
	OutputStream out;
	InputStream inpStream;
	String message;
	String hostName;
	Requester(String hostName){
		this.hostName = hostName;
	}

	public int connect(){
		try{
			//1. creating a socket to connect to the server
			requestSocket = new Socket();
			requestSocket.connect(new InetSocketAddress(hostName, 27015), 5000);
			System.out.println("Connected to localhost in port 27015");
			//2. get Input and Output streams
			out = requestSocket.getOutputStream();
			out.flush();
			inpStream = requestSocket.getInputStream();
		}
		catch(UnknownHostException unknownHost){
			System.err.println("You are trying to connect to an unknown host!");
			return 1;
		}
		catch(IOException ioException){
			ioException.printStackTrace();
			return 1;
		}
		System.out.println("connected");
		return 0;
	}
	
	public String read(){
		String result = "Fail";
		int bytesAvailable = 0;
			if(inpStream != null){
			try {
				bytesAvailable = inpStream.available();
				if(bytesAvailable > 0){
					byte b[] = new byte[100];
					inpStream.read(b);
					String receivedBytes = new String(b, 0, bytesAvailable, Charset.defaultCharset());
					System.out.println("server> " + receivedBytes + " " + bytesAvailable);
					if(receivedBytes.length() > 2)
						result = receivedBytes.substring(0, receivedBytes.length()-2);
				}
			} catch (IOException e) {
				e.printStackTrace();
				System.out.println("read exception>" + e);
			}
		}
		return result;
	}
	
	void close(){
		try{
			if(inpStream != null){
				inpStream.close();
				inpStream = null;
			}

			if(out != null){
				out.close();
				out = null;
			}
			
			if(requestSocket != null){
				requestSocket.close();<commit_msg>fix buffer overflow crash in android app<commit_after>package com.lion.rmtsndcli;

import java.io.*;
import java.net.*;
import java.nio.charset.Charset;

public class Requester{
	Socket requestSocket;
	OutputStream out;
	InputStream inpStream;
	String message;
	String hostName;
	Requester(String hostName){
		this.hostName = hostName;
	}

	public int connect(){
		try{
			//1. creating a socket to connect to the server
			requestSocket = new Socket();
			requestSocket.connect(new InetSocketAddress(hostName, 27015), 5000);
			System.out.println("Connected to localhost in port 27015");
			//2. get Input and Output streams
			out = requestSocket.getOutputStream();
			out.flush();
			inpStream = requestSocket.getInputStream();
		}
		catch(UnknownHostException unknownHost){
			System.err.println("You are trying to connect to an unknown host!");
			return 1;
		}
		catch(IOException ioException){
			ioException.printStackTrace();
			return 1;
		}
		System.out.println("connected");
		return 0;
	}
	
	public String read(){
		String result = "Fail";
		int bytesAvailable = 0;
			if(inpStream != null){
			try {
				bytesAvailable = inpStream.available();
				if(bytesAvailable > 0){
					byte b[] = new byte[64];
					while(bytesAvailable > 40){
						inpStream.read(b, 0, 30);
						bytesAvailable -= 30;
						System.out.println("server read drop 30>");
					}
					inpStream.read(b);
					String receivedBytes = new String(b, 0, bytesAvailable, Charset.defaultCharset());
					System.out.println("server> " + receivedBytes + " A" + bytesAvailable);
					if(receivedBytes.length() > 2)
						result = receivedBytes.substring(0, receivedBytes.length()-2);
				}
			} catch (IOException e) {
				e.printStackTrace();
				System.out.println("read exception>" + e);
			}
		}
		return result;
	}
	
	void close(){
		try{
			if(inpStream != null){
				inpStream.close();
				inpStream = null;
			}

			if(out != null){
				out.close();
				out = null;
			}
			
			if(requestSocket != null){
				requestSocket.close();
{'fraction_non_alphanumeric': 0.12924993511549443, 'fraction_numerical': 0.016610433428497273, 'mean_word_length': 3.4146620847651774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '971149', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1188, 'n_words': 305}