Hello friend,
I have following java code, which will demonstrate you about how to declare and use the "socket in java":
Code:
import java.io.*;
import java.net.*;
public class FibReader
{
Socket appSoct;
BufferedReader inj;
String messaget;
public static void main(String argi[]) {
try {
appSoct = new Socket("wherever",2001);
inj = new BufferedReader(new InputStreamReader(appSoc.getInputStream()));
for (int im = 0; im < 100; im++) {
message = inj.readLine();
System.out.println(messaget); }
}
catch (Exception e) {
System.out.println("Died... " + e.toString());
}
}
Bookmarks