Hüseyin Çelik Blog Sayfasi

.Net, Java, Android, Progress 4gl Paylasimlarim

Android üzerinden TCP port baglantisi kurma

Socket mySocket = new Socket("10.48.1.137", 21000);
mySocket.setSoTimeout(10000);
OutputStream outputStream = mySocket.getOutputStream();
if (null != outputStream) {
	PrintWriter outDeviceSocket = new PrintWriter(outputStream, true);
	outDeviceSocket.println(prepareUnicodeCommand("CR"));
	outDeviceSocket.flush();
	InputStream input = mySocket.getInputStream();
	if (input != null) {
		bufferedReader = new BufferedReader(new InputStreamReader(input));
	}
}

Android üzerinden baska bir cihazla haberlesme gereken durumlarda isinize yarayacak bir kod.

Loading