Server
--------------------------------------------------------------------------------
Client
So wie oben beschrieben habe ich versucht n ByteArray per Netzwerk zu verschicken was leidern nicht ging.
Einer ne Idee wie ich dsa regeln könnte?
Code:
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class TestServer {
public static void main(String[] args) throws Exception {
ServerSocket servSock = new ServerSocket(502);
while( true ) {
Socket clientSock = servSock.accept();
DataInputStream clientIn = new DataInputStream(clientSock.getInputStream());
DataOutputStream clientOut = new DataOutputStream(clientSock.getOutputStream());
System.out.println(clientIn.read());
}
}
}
Client
Code:
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;
public class TestClient {
public static void main(String[] args) throws Exception {
byte[] rqBuffer = new byte[256];
byte[] rpBuffer = new byte[256];
Socket clientSock = new Socket("localhost", 502);
DataInputStream clientIn = new DataInputStream(clientSock.getInputStream());
DataOutputStream clientOut = new DataOutputStream(clientSock.getOutputStream());
rqBuffer[0] = 0x00;
rqBuffer[1] = 0x00;
rqBuffer[2] = 0x00;
rqBuffer[3] = 0x00;
rqBuffer[4] = 0x00;
rqBuffer[5] = 0x00;
rqBuffer[6] = 0x00;
rqBuffer[7] = 0x00;
rqBuffer[8] = 0x00;
rqBuffer[9] = 0x00;
rqBuffer[10]= 0x00;
for( int i=0; i<rqBuffer.length; i++ ) {
System.out.println(rqBuffer[i]);
clientOut.write(rqBuffer[i]);
}
}
}
So wie oben beschrieben habe ich versucht n ByteArray per Netzwerk zu verschicken was leidern nicht ging.
Einer ne Idee wie ich dsa regeln könnte?