package com.evs.objava33.class10;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.Socket;
public class ChatClient {
public static void main(String[] args) {
try {
Socket client = new Socket("127.0.0.1", 6666);
// Here you are connected
BufferedOutputStream out = new BufferedOutputStream(
client.getOutputStream());
BufferedInputStream in = new BufferedInputStream(
client.getInputStream());
BufferedInputStream keyboard = new BufferedInputStream(System.in);
byte[] bKey = new byte[1024];
// byte[] bIn = new byte[1024];
// byte[] bOut = new byte[1024];
while (true) {
int readKey = keyboard.read(bKey); // Read from Keyboard
out.write(bKey, 0, readKey); // Write to client
out.flush();
}
// int readClient = in.read(bIn); // Input Buffer from Client
// System.out.println("Client: " + new String(bIn, 0, readClient));
} catch (IOException e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment