Results 1 to 3 of 3
  1. #1
    Dennis's Avatar
    Dennis is offline Member
    Join Date
    May 2010
    Posts
    83
    Rep Power
    0

    Default [Socket] Send audio data

    I wanna create an program with an server-client connection.

    Server loads the .wav file > Send it to file while playing.
    All clients are synchroned with the sound.

    I allready can load a .wav file in an program and play it, but not over socket.
    Can someone help me?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Dennis View Post
    I allready can load a .wav file in an program and play it, but not over socket.
    Can someone help me?
    Going to be hard to do without details -- what you've tried and doesn't work, what you don't understand,... etc

  3. #3
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Once you've loaded a WAV file, it's just bytes. You can send it over sockets like anything else.

    pseudo-code for server
    Java Code:
    ServerSocket serverSocket = new ServerSocket(port);
    
    Socket socket = serverSocket.accept();
    
    socket.getOutputStream().write(bytes);
    pseudo code for client
    Java Code:
    Socket socket = new Socket(host, port);
    
    socket.getInputStream().read(bytes);
    
    ...
    There are a *lot* of detailes obscured in these code snippets, such as error handling, how to deal with multiple clients on the server using multiple threads, clean up of the sockets when you shut them down, fully reading off a socket, etc.

Similar Threads

  1. How to send folder through a connected socket
    By Chris555 in forum Networking
    Replies: 0
    Last Post: 07-18-2009, 12:41 PM
  2. Server socket - send image to client
    By Hinty in forum Networking
    Replies: 2
    Last Post: 03-14-2009, 08:39 AM
  3. to send float array with TCP socket
    By zeyneqp in forum Networking
    Replies: 6
    Last Post: 08-30-2008, 04:48 AM
  4. Send an array via Socket
    By lene in forum Networking
    Replies: 0
    Last Post: 04-23-2008, 05:29 PM
  5. send files through socket
    By bbq in forum Advanced Java
    Replies: 1
    Last Post: 06-05-2007, 03:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •