编程处理,无法绑定到网络中的udp端口

时间:2013-03-01 15:29:28

标签: udp processing

我有一个处理本地计算机的处理程序。它从本地udp端口读取数据,并使用此数据在屏幕上绘制圆圈。它很有用,非常好。

但在制作中,程序必须在另一台计算机上运行。我无法让它发挥作用。 Processing正在向我显示以下错误消息:

opening socket failed!
> address:192.168.1.118, port:6666 [group:null]
> Cannot assign requested address: Cannot bind

在cource中我检查了IP地址,这些都没关系,因为它在本地计算机上运行正常。这是我的UDP部分代码:

// import UDP library
import hypermedia.net.*;

String HOST_IP = "192.168.1.118";
UDP udp;  // define the UDP object

// get an array ready 
int num = 20;
int[] xx = new int[num];
int[] yy = new int[num];


void setup() {
size(1024, 768);
smooth();
//noStroke();

// create a new datagram connection on port 6666
udp = new UDP(this, 6666, HOST_IP);
udp.listen( true );
}



//process events
void draw() {;}
/**
* To perform any action on datagram reception, you need to implement this 
* handler in your code. This method will be automatically called by the UDP 
* object each time he receive a nonnull message.
* By default, this method have just one argument (the received message as 
* byte[] array), but in addition, two arguments (representing in order the 
* sender IP address and his port) can be set like below.
*/
// void receive( byte[] data ) {       // <-- default handler
void receive( byte[] data ) {  

background(255);

// get the "real" message =
// forget the ";\n" at the end <-- !!! only for a communication with Pd !!!

 data = subset(data, 0, data.length-2);
String message = new String( data );

// print the result
println(message );

在两台机器上我都使用Windows XP它们通过交换机和udp电缆连接。

我不知道从哪里开始进行故障排除以及如何进行故障排除。有什么想法吗?

0 个答案:

没有答案