P
palmis
Hi,
I want to receive, by tcp/ip protocol, a stream that is a message with
specific field of specific dimension (some of 2 byte, other of 4 byte
and so on......)
I want to read it byte to byte. How can I do?
This is TCP/IP client code
import java.net.*;
import java.io.*;
public class TCPServer {
public static final int PORT=7777;
public void start() throws IOException {
ServerSocket serverSocket = new ServerSocket(PORT);
while (true) {
Socket socket = serverSocket.accept();
DataInputStream is = new
DataInputStream(socket.getInputStream());
DataOutputStream os = new
DataOutputStream(socket.getOutputStream());
while (true) {
byte userInput=is.readByte();
???????? How can I control the end of stream
?????????????
os.close();
is.close();
socket.close();
}
}
public static void main (String[] args) throws Exception {
TCPServer tcpServer = new TCPServer();
tcpServer.start();
}
}
Palmis
I want to receive, by tcp/ip protocol, a stream that is a message with
specific field of specific dimension (some of 2 byte, other of 4 byte
and so on......)
I want to read it byte to byte. How can I do?
This is TCP/IP client code
import java.net.*;
import java.io.*;
public class TCPServer {
public static final int PORT=7777;
public void start() throws IOException {
ServerSocket serverSocket = new ServerSocket(PORT);
while (true) {
Socket socket = serverSocket.accept();
DataInputStream is = new
DataInputStream(socket.getInputStream());
DataOutputStream os = new
DataOutputStream(socket.getOutputStream());
while (true) {
byte userInput=is.readByte();
???????? How can I control the end of stream
?????????????
os.close();
is.close();
socket.close();
}
}
public static void main (String[] args) throws Exception {
TCPServer tcpServer = new TCPServer();
tcpServer.start();
}
}
Palmis