Again, this code doesn't work:
import org.apache.tomcat.jni.*;
import java.util.*;
public class ExampleAPR {
public static void main(String[] args) {
int err = 0;
try {
// Initialize APR library
Library.initialize(null);
// Create pool
long pool = Pool.create(0);
// Create socket
long s = Socket.create(Socket.APR_INET,
Socket.SOCK_STREAM,
Socket.APR_PROTO_TCP,
pool);
// Bind to port
long addr = Address.info(null,
Socket.APR_INET,
Integer.parseInt(args[0]),
0, pool);
Socket.bind(s, addr);
Socket.listen(s, 5);
long set = Poll.create(10, pool, 0, 10);
if ((err = Poll.add(set, s, Poll.APR_POLLIN)) != 0)
System.out.println("Poll.add: "
+ org.apache.tomcat.jni.Error.strerror(err));
long[] desc = new long[2];
if ((err = Poll.poll(set, -1, desc, false)) != 0)
System.out.println("Poll.poll: "
+ org.apache.tomcat.jni.Error.strerror(err));
System.out.println("after poll");
long ns = Socket.accept(s);
byte[] recchars = new byte[80];
Socket.recv(ns, recchars, 0, 80);
System.out.println(new String(recchars));
} catch(org.apache.tomcat.jni.Error e) {
System.out.println("Error");
e.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}
}
}
Three things:
1.-
call Poll.poll fails with:
Poll.poll: Unknown error 4294847295
Should block at it, right?
2.-
It is unclear to me which value to put in 4th parameter
(time to live) of:
long set = Poll.create(10, pool, 0, 10);
3.-
Socket.recv(ns, recchars, 0, -1) doesn't work. I'd to put full byte[]
length (80)
Couldn't find any sample code that could enlighten these questions.
Regards, francesc
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]