# Send an audio with server

**URL:** <https://discourse.processing.org/t/send-an-audio-with-server/20513>\
**Category:** Libraries\
**Created:** [May 5, 2020, 3:28pm UTC](https://discourse.processing.org/t/send-an-audio-with-server/20513 "2020-05-05T15:28:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hydent](https://avatars.discourse-cdn.com/v4/letter/h/8491ac/32.png) [@Hydent](https://discourse.processing.org/u/Hydent)\
**Post date:** [May 5, 2020, 3:28pm UTC](https://discourse.processing.org/t/send-an-audio-with-server/20513/1 "2020-05-05T15:28:49Z")

</div>

I want to create a program to send an audio with server and receive like discord but on LAN.  
Here is the code who is for start

```auto
import processing.net.*;
import processing.sound.*;

Server server; 
Client client;
String input;
int data[];
int port;
String stat;
int v;
AudioIn in;

void setup() {
  stat ="online";
  size(800,100);
  port = 8670;
  background(204);
  stroke(0);
  frameRate(3); // Slow it down a little
  server = new Server(this, port); // Start a simple server on a port
  in = new AudioIn(this, 0);
  server.write(in);
} 
void draw() { 
  text(stat,0,20);
  
  // Receive data from client
  client = server.available();
  if (client != null) {
    input = client.readString(); 
    input = input.substring(0, input.indexOf("\n")); // Only up to the newline
    data = int(split(input, ' ')); // Split values into an array
    // Draw line using received coords
    stroke(0);
    line(data[0], data[1], data[2], data[3]); 
  }
}
void keyPressed()
{
  if(keyCode==UP){v = v+1;}
}

```

---

<div class="post-metadata">

**Author:** ![KevinWho](https://avatars.discourse-cdn.com/v4/letter/k/dbc845/32.png) [@KevinWho](https://discourse.processing.org/u/KevinWho)\
**Post date:** [May 15, 2020, 5:47pm UTC](https://discourse.processing.org/t/send-an-audio-with-server/20513/2 "2020-05-15T17:47:34Z")

</div>

You could send the raw byte data.  
Take a look at this:  
[https://processing.org/reference/loadBytes\_.html](https://processing.org/reference/loadBytes_.html)  
[https://processing.org/reference/saveBytes\_.html](https://processing.org/reference/saveBytes_.html)  
Then you could save it, load it, and play it.
