• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Socket Programming (Sending Smileys and audio)

 
Shyam Prasad Murarka
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Readers,
I want to know how to send Smileys over the sockets in my chat program. I have no experience in handling Images.
Also, I wanted to know how to enable audio transferring so that my chat program gains audio communication.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the ranch!

Do you have text messaging up & running already? Not knowing you you have I'll be guessing a bit ...

Sending images or sounds will probably be a new protocol for you, maybe sending bytes instead of characters using streams instead of readers and writers. You might send an indicator of whether the following message is text, image or sound, then send the size and finally the bytes. Or you might use additional port numbers for images and sounds. Displaying images or playing sound are a couple more topics ... and I can't help you much with those.

Let me know if that was confusing or painfully obvious or somewhere in between.
[ May 02, 2005: Message edited by: Stan James ]
 
Shyam Prasad Murarka
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Stan,
Thank you very much for your reply. Actually, I don't even know how to convert images and audio into bytes. Also, I was thinking of grabbing the pixels of a particular image and sending an array of those pixels to the other side.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shyam, you are asking some non-trivial questions here. First, sending bytes of anything is covered in the Java IO tutorial. Sending an image is simple enough, just read the file and write to a socket. Like Stan was saying, you need some way to tell the image data from the text, using different sockets or some sort of protocol. Sending audio is much more complicated and requires the Java Media Framework.
You should start small. Have you looked at how smilies are done on this site? You write a semicolon and a right parenthesis and it gets rendered as . Study up on how Swing separates the data and how data is represented. It should be pretty easy to watch a stream for some special characters and render them as smilies. Once you get that working you'll be in a better position to tackle the more complex stuff.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!