-1

I was doing a program for my friends and me so we can chat and send file's to each other BUT I find something that maked me confused. That was when I was making the last stage of the program, combining the chat and file functions. But I didn't know HOW to combine this two. Because the chat have one input stream and one output BUT the file function GOT THREE streams:

fis = new FileInputStream(myFile);
bis = new BufferedInputStream(fis);
os = sock.getOutputStream();

And this is the chat function streams:

    outputdata = new ObjectOutputStream(connect.getOutputStream());
    inputdata = new ObjectInputStream(connect.getInputStream());

So how should I combine this programs, if this is too little information here's a short explanation: I want to do a chat AND file transfer program with Java socket but how should I do so the streams are correct so it know when it ONLY should send text or when it ONLY should send file's.

Thanks for and answer :D!

Tor
  • 3
  • 7

1 Answers1

0

if you use socket and send the data is like dedicated chat. you might want to use MulticastSocket to make a chat where your message is visible all others who are in that group.

http://download.java.net/jdk7/archive/b123/docs/api/java/net/MulticastSocket.html

Dineshkumar
  • 4,165
  • 5
  • 29
  • 43
  • No not that answer, How should I put the file transfer code and the chat code togheter – Tor Sep 26 '14 at 16:35