• Post Reply Bookmark Topic Watch Topic
  • New Topic

send WAV/ Files Over Socket

 
travis Haycock
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im trying to send a WAV file over a socket I have successfully created a method to obtain sound from my mic and put it into a WAV file I am having difficulties sending it through to my server though and vice versa. I have spent a few hours now spinning my wheels trying to figure it out and have used up most the resources I have available. Im going tp post the code I have been playing with (just the part that performs the method in question) as the creation of a WAV file from my mic is working just fine. Would appreciate any help on this looking forward to tackling it and understanding whats going on.

CLIENT



SERVER
 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should never really use the available() method, it's not reliable. I also don't understand why you're writing binary data using an ObjectOutputStream. Regular OutputStreams are just fine for sending binary data. You should also close all your resources using a try-with-resources:

Now, do something similar at the receiving end.
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:You should never really use the available() method, it's not reliable.

We even have an FAQ entry about it: Available doesn't do what you think it does.
 
travis Haycock
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for your insight it helped. I have got the problem resolved and unfortunately have a new problem I really cannot crack. I will post the new issue on a separate thread, thank you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!