I have java tcp socket programming...... In that i need to send a file from client to server .... at the same time i need to chat with that client ...... by what way i can do this ...
You could open two connections, one for the file transfer and the other for the chat. Each would run in its own thread.
how can i open two connection ... i didnt understand
The same way that you open one!
In the the client just create two Sockets and connect them both to the server. At the server you will get two accepts, and thus two ServerSockets. Now you can use one pair of sockets for the file xfer and the other pair for chat.
thanks .....ya it is good ...... but when it is used for multiple clients ... is it possible ?????
Yes. Provided your server has enough capacity you can have many many clients (each with one or more connections) all communicating at the same time. Each connection just starts a new Thread on the server.
k my server is keep on searchin for new client ..... at the time how can i connect the second connection..... to send the file with the same port....
In your server you have a loop that starts with a accept(). When you get an incoming connection the accept returns you a ServerSocket. You then start a new Thread, passing in that ServerSocket, and process all the I/O for that connection in that thread. Your loop then goes back to waiting for another incoming connection.
Server-It ill keep on running to accept the connection...... When it is accept a connection it ill open an frame with chat and send file ....... If a new connection will came it ill again open a frame with chat and send file.....
You just need to run the "open an frame with chat and send file" code in a new Thread so you can have more than one going at the same time.
Thank you i ill try it now...... :)
Thread means a Java class, It using for the multi threads process.