So I am writing a game of LAN tic-tac-toe. I have the "board" stored as a 2 dimensional char
array. I want to be able to send and receive this array through Sockets. I am currently using a InputStream
and OutputStream
to send single bytes. However, I don't think this will work for sending the array. Also, these streams only seem capable of sending int
type data. Can someone please explain to me how too send 2 dimensional char
arrays over sockets using I/O streams. Example code would be great! Thanks.
Current Code:
public void communicate() {
try {
OutputStream os = client.getOutputStream();
InputStream is = client.getInputStream();
}
while (gameOver == false) {
char[][] board = new char[3][3];
try {
os.write(board); //this dosen't work, only sends non-array int types.
} catch (IOException e) {
e.printStackTrace();
}
}
}