J
Josh
Hi
I'm trying to send data with a datagramsocket over ipv6 on a windows
machine. I keep getting this "BindException : Cannot assign requested
address" error on my DatagramSocket.send method.
After spending more than a day searching the web i found nothing, so this
newsgroup is my last stop before returning to C# (where this is EASY...)
hope to get an answer
my complete source :
import java.net.*;
import java.io.IOException;
public class StreamingClient
{
public static void main(String[] args) throws IOException
{
if (args.length != 1)
{
System.out.println("Usage: java StreamingClient <hostname>");
return;
}
System.out.println("starting stream");
DatagramSocket socket = new DatagramSocket();
// socket.bind(new InetSocketAddress(4557));
byte[] buf = generateSmpls(1000, 800, 8000);
InetAddress address = InetAddress.getByName(args[0]);
System.out.println(address.getHostAddress());
DatagramPacket packet = new DatagramPacket(buf, buf.length, address,
5160);
System.out.println(packet.getSocketAddress());
socket.send(packet);
}
private static byte[] generateSmpls(double freq, int N, double samplrate)
{
double period = 1 / samplrate;
double time = 0;
byte[] smpls = new byte[N];
for (int i = 0; i < N; i++)
{
smpls = (byte) (Math.sin(2 * Math.PI * freq * time) * 120 + 128);
// smpls = (byte) Math.sin(5);
time += period;
}
return smpls;
}
}
I'm trying to send data with a datagramsocket over ipv6 on a windows
machine. I keep getting this "BindException : Cannot assign requested
address" error on my DatagramSocket.send method.
After spending more than a day searching the web i found nothing, so this
newsgroup is my last stop before returning to C# (where this is EASY...)
hope to get an answer
my complete source :
import java.net.*;
import java.io.IOException;
public class StreamingClient
{
public static void main(String[] args) throws IOException
{
if (args.length != 1)
{
System.out.println("Usage: java StreamingClient <hostname>");
return;
}
System.out.println("starting stream");
DatagramSocket socket = new DatagramSocket();
// socket.bind(new InetSocketAddress(4557));
byte[] buf = generateSmpls(1000, 800, 8000);
InetAddress address = InetAddress.getByName(args[0]);
System.out.println(address.getHostAddress());
DatagramPacket packet = new DatagramPacket(buf, buf.length, address,
5160);
System.out.println(packet.getSocketAddress());
socket.send(packet);
}
private static byte[] generateSmpls(double freq, int N, double samplrate)
{
double period = 1 / samplrate;
double time = 0;
byte[] smpls = new byte[N];
for (int i = 0; i < N; i++)
{
smpls = (byte) (Math.sin(2 * Math.PI * freq * time) * 120 + 128);
// smpls = (byte) Math.sin(5);
time += period;
}
return smpls;
}
}