it read correctly but it only correctly only when got one client. so i do not know how to change to program
it read correctly but it only correctly only when got one client. so i do not know how to change to program
do you know the program got what problem?
your straight run 2 client? it run smoothly ?
SERVER
import java.awt.BorderLayout;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
Success entering
reading log
writing log to the server
1
writing message to the server
message 3
Success read log from client = 1
reading msg from client store in allmessage[chatlog]
read...
it show that the server's log = inputFromClient.readInt() read successful then it go to another read (allmessage[chatlog] = inetAddress.getHostName() + "\t" +inputFromClient.readUTF(); ) after...
before server and client show they read each other int log = inputFromClient.readInt(); (in the server read successful), but when it come to allmessage[chatlog] = inetAddress.getHostName() + "\t"...
at server
allmessage[chatlog] = inetAddress.getHostName() + "\t" +inputFromClient.readUTF();
try to read from client's
toServer.writeUTF(jtfMessage.getText().trim());
at client
log =...
nope...the last two statement is server and client try to read each other
example like the server read the Int from the client so that the server can store the message inside String array at the server .
and let say if the second client already got input in the server ...
the debug show the server read first then followed by client read, then it stop already.
program is for client to enter the data..then the server read, after read server update the data then give...
i not really good at debug but i still try it, i just realize that after the second client run then back to first client to run..it stop at log = fromServer.readInt(); , but the server there is...
public void run(){
try{
while(true){
String msgtoreturn = "";
int log = inputFromClient.readInt();
...
all client have the same code... when i open one client(first client) the action listener does not have any problem. then i open second client and do the same..the action listener also does have any...
jtfMessage.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
toServer.writeInt(log);
...
server
import java.awt.BorderLayout;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
erm....i already make changes to my code . that matching problem already solve but it come back to last time problem, the first client read there cannot work after the second client run. The read i...
i use println to debug . at server i use writeInt and writeUTF ,client there use readInt and readUTF
but the value i readInt is different from writeInt when my server there have another writeUTF
mind to show me some example?
this time,i straight cannot input . it seem like the read cannot be use when got more than one client . what other method can be use ,because i want message to be update when i press enter
i replace the main inside client with the driver.
Sorry for not able to provide more detail for you all to help me
i use that driver , it help open so many server. only one server can be use, the rest (java.net.BindException: Address already in...
1813
I was hope that the server will store the input from the client( it store in an String array in the server), when another(second) client it open and have input into the server the server...
jtfMessage.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
toServer.writeInt(log);
toServer.writeUTF(jtfMessage.getText().trim());
toServer.flush();
sorry for make you all hard to understand . It my first experience to use forum.
the problem is when i open second client and use it still ok...but then i change back to first client (i hope the...