[zeromq-dev] Subscribing in JAVA api
gonzalo diethelm
gdiethelm at dcv.cl
Wed May 12 16:10:29 CEST 2010
> Instead of
> int rc = zmq_setsockopt (s, option, value, strlen (value));
> maybe do
> int rc = zmq_setsockopt (s, option, value, env-> GetStringUTFLength
> (optval));
Robin, I think you are right. How about this: in Java, define two
setsockopt functions:
public void setsockopt (int option,
String optval)
{
Setsockopt(option, optval, -1);
}
public native void setsockopt (int option,
String optval,
int optvallen);
Then, in native code, do this:
if (optvallen < 0)
optvallen = env->GetStringUTFLength (optval);
int rc = zmq_setsockopt (s, option, value, optvallen);
This way you can force the length of the string to whatever you want,
just like it is done for the C interface. What do you think?
The only doubt I have is this: what is the difference between
const char *value = env->GetStringUTFChars (optval, NULL);
optvallen = strlen(value);
and
optvallen = env->GetStringUTFLength (optval);
Which one should we actually be using?
--
Gonzalo Diethelm
-----------------------------------------
Declaración de confidencialidad: Este Mensaje esta destinado para
el uso de la o las personas o entidades a quien ha sido dirigido y
puede contener información reservada y confidencial que no puede
ser divulgada, difundida, ni aprovechada en forma alguna. El uso no
autorizado de la información contenida en este correo podrá ser
sancionado de conformidad con la ley chilena.
Si usted ha recibido este correo electrónico por error, le pedimos
eliminarlo junto con los archivos adjuntos y avisar inmediatamente
al remitente, respondiendo este mensaje.
"Before printing this e-mail think if is really necesary".
Disclosure: This Message is to be used by the individual,
individuals or entities that it is addressed to and may include
private and confidential information that may not be disclosed,
made public nor used in any way at all. Unauthorized use of the
information in this electronic mail message may be subject to the
penalties set forth by Chilean law.
If you have received this electronic mail message in error, we ask
you to destroy the message and its attached file(s) and to
immediately notify the sender by answering this message.
More information about the zeromq-dev
mailing list