Re: Return Complex Types.

2010-04-26 Thread Stanislav Miklik
Hi,

since you don't get a class cast exception, everything seems to be working
as it should be.
in your print you probably get something like [Ljava.lang.Object;@1100d7a
but this means that you have array of Objects

Thus you can access the first person as people[0].
The corresponding type will be based on how the array of people was
constructed.

BR
Stano

On Mon, Apr 26, 2010 at 20:44, David J. da...@styleflare.com wrote:

 How do I access an Array that is returned in a HashMap?

 The server returns a HashMap with the following values

 {responseCode=OK,people=[Array of People]}

 I cast the response to a HashMap which then lets me access the  objects by
 key,
 although the Array simple returns Object, and I cant access the Data.

 ie I call

 HashMap response = (HashMap)client.execute(myMethod,param);

 String responseCode =  (String)response.get(responseCode);
 System.out.println(responseCode); (Prints OK);

 Object[] people = (Object[]) response.get(people);
 System.out.println(people); (Prints java.lang.Object);

 Anyone can help me?



Re: Design question

2010-02-03 Thread Stanislav Miklik
Hi,

I am not so familiar with the implementation of web server, but maybe I have
one general hint. You may have consider using singleton pattern, i.e. class
that implements XML-RPC methods will forward requests to the singleton that
can access directly your initialized objects (also non-static).

Regards
Stano

On Wed, Feb 3, 2010 at 19:29, Lars Schnoor lars.schn...@ifad.dk wrote:

 Hi
 I am using XML-RPC for a control interface for my application. My
 application starts a web server which loads the class that provides the
 XML-RPC methods.
 I believe that the web server creates a new object of the class that
 implements the XML-RPC methods each time a XML-RPC method is invoked. This
 is not a problem as long as the methods do simple things like the calculator
 example, but if the method should manipulate data that is not passed in by
 the method it becomes a bit more complicated.

 When my application starts up I create and initialize some objects, the
 XML-RPC based interface is used to manipulate the objects in my application,
 but since the interface class gets initialized for every method invocation I
 need to make my methods to manipulate the objects static and invoke them
 from the XML-RPC interface. Having to have all methods that should be
 invoked by the XML-RPC interface static is become more and more a problem. I
 was therefore wondering if it is possible to create and initialize the
 XML-RPC interface once and have the web server use this object again and
 again?
 Thanks in advance!

 Lars



Re: class cast exception with array return result

2009-10-13 Thread Stanislav Miklik
Hi,

you are right, there is a bug in FAQ.
the point is, that you can not cast the result of the XML RPC call, in your
case

return (String []) windows.getInstances(category);

is the problem.
You have to transform the result to String[] as described in the FAQ (but
without the cast in the first line of FAQ example)

If you have any further questions, pls, ask ;-)
Regards

Stano

On Tue, Oct 13, 2009 at 19:06, christopher.coo...@rsa.com wrote:

 I am continuing this from my bug post (sorry).
 I am having difficulty with an array not being cast properly. I have done
 what is outlined on here as far as I can tell.
 http://ws.apache.org/xmlrpc/faq.html#arrays

 This is the issue I opened for some background info
 https://issues.apache.org/jira/browse/XMLRPC-178

 I have done what is in the last comment, and I am still getting the class
 cast exception, I am really unsure where to go from here and any help would
 be much appreciated.

 Thanks,
 _
 Christopher Cooper
 Performance Engineer
 RSA Security
 781-515-7141




Re: XmlRpcHttpTransportException (apache xmlrpc client, xmlrpc-c C++ server)

2009-07-12 Thread Stanislav Miklik
Hi,

I am not sure, but to me it looks like the problem on HTTP level (guess
404). Also I would try to capture the good case (with C++ client) and the
bad case (Java) with Wireshark / snoop and compare the HTTP request.
However it looks strange, but I would guess some different interpretation of
sample.add

Regards
Stano

On Sun, Jul 12, 2009 at 18:31, Lars Schnoor lars.schn...@ifad.dk wrote:

 Hi
 I am not sure if I can come with any useful for you, but I would try
 changing the argument to you function call from Vector to Object[]. My
 server runs Apaches XML-RPC and I have managed to use it with both xml-rpc
 for c and for c++.

 Lars


 Arne Kalaghan wrote:

 Hello,
 I have problems connecting an apache java xml-rpc client with a xmlrpc-c
 C++ xml-rpc server (system is ubuntu linux 8.04).

 The client code is modified from the first example at
 http://www.wordtracker.com/docs/api/ch03s02.html.

 The server code is
 http://xmlrpc-c.svn.sourceforge.net/viewvc/xmlrpc-c/trunk/examples/cpp/xmlrpc_sample_add_server.cpp?revision=1083view=markup

 When running the client (after server is started) I get:
 Exception
 in thread main org.apache.xmlrpc.client.XmlRpcHttpTransportException:
 HTTP server returned unexpected status: Not Found
at
 org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:94)
at
 org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:152)
at
 org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:115)
at
 org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at
 org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
at test.apachexmlrpc.Client.main(Client.java:9)

 The
 java client can communicate with a server from the same apache package,
 and the C++ server can communicate with a C++ client from the same
 xmlrpc-c package. What can be the reason for the incompatibilities
 between java and C++?

 Here are the sources for completeness:

 Java client Client.java:
 

 import org.apache.xmlrpc.XmlRpcClient;
 import java.util.Vector;
 public class Client {
public static void main( String args[] ) throws Exception {
XmlRpcClient client = new XmlRpcClient( http://localhost:8080/;
 );
Vector params = new Vector();
params.addElement( 5 );
params.addElement( 7 );
Object result = client.execute( sample.add, params );
if ( result != null )
System.out.println( Successfully pinged guest account. );
}
 }

 C++ server xmlrpc_sample_add_server.cpp:
 
 #include cassert
 #include stdexcept
 #include iostream
 #ifdef WIN32
 #  include windows.h
 #else
 #  include unistd.h
 #endif

 #include xmlrpc-c/base.hpp
 #include xmlrpc-c/registry.hpp
 #include xmlrpc-c/server_abyss.hpp

 using namespace std;

 #ifdef WIN32
  #define SLEEP(seconds) SleepEx(seconds * 1000);
 #else
  #define SLEEP(seconds) sleep(seconds);
 #endif


 class sampleAddMethod : public xmlrpc_c::method {
 public:
sampleAddMethod() {
// signature and help strings are documentation -- the client
// can query this information with a system.methodSignature and
// system.methodHelp RPC.
this-_signature = i:ii;
// method's result and two arguments are integers
this-_help = This method adds two integers together;
}
void
execute(xmlrpc_c::paramList const paramList,
xmlrpc_c::value *   const  retvalP) {

int const addend(paramList.getInt(0));
int const adder(paramList.getInt(1));

paramList.verifyEnd(2);

*retvalP = xmlrpc_c::value_int(addend + adder);

// Sometimes, make it look hard (so client can see what it's like
// to do an RPC that takes a while).
if (adder == 1)
SLEEP(2);
}
 };



 int main(int   const, const char ** const) {

try {
xmlrpc_c::registry myRegistry;

xmlrpc_c::methodPtr const sampleAddMethodP(new sampleAddMethod);

myRegistry.addMethod(sample.add, sampleAddMethodP);

xmlrpc_c::serverAbyss myAbyssServer(
myRegistry,
8080,  // TCP port on which to listen
/tmp/xmlrpc_log  // Log file
);

myAbyssServer.run();
// xmlrpc_c::serverAbyss.run() never returns
assert(false);
} catch (exception const e) {
cerr  Something failed.e.what()  endl;
}
return 0;
 }

 Kind regards,
 A. Kalaghan







Re: Passing an array of strings

2009-07-08 Thread Stanislav Miklik
Hi,

AFAIK, you are right, option A is the way how it works (see:
http://ws.apache.org/xmlrpc/faq.html#arrays)
My only advice, make small tooling, eg.

   public static List decodeList(Object element) {
  if (element == null) {
 return null;
  }
  if (element instanceof List) {
 return (List) element;
  }
  if (element.getClass().isArray()) {
 int length = Array.getLength(element);
 LinkedList result = new LinkedList();
 for (int i = 0; i  length; i++) {
result.add (Array.get(element, i));
 }
 return result;
  }
  return null;
   }

With such method you can have option B.

Best regards
Stano

On Wed, Jul 8, 2009 at 23:37, Ken Tanaka ken.tan...@noaa.gov wrote:

 I'm using an xmlrpc-client 3.1.2 application to talk to an xmlrpc-server
 3.1.2 server and want to pass an array of strings. I figure people on this
 list must have done this before.

 This code below is working, but could probably be written better. Does
 anyone have suggestions on cleaning up the 5 lines following the comment
 OPTION A?. The two lines (commented out) following the comment OPTION B
 are what I would have expected to work, but throw 'Exception in thread
 main java.lang.ClassCastException: [Ljava.lang.Object;'

 Thanks in advance for any suggestions.

 -Ken

 - Begin client code listing 

 package gov.noaa.eds.adicXmlRpcClient;

 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import org.apache.xmlrpc.XmlRpcException;
 import org.apache.xmlrpc.client.XmlRpcClient;
 import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

 /**
 * This client will use the adicXmlRpcServer.
 */
 public class App {

   public static void main(String[] args) {
   System.out.println(Starting adicXmlRpcServer test);

   XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
   try {
   config.setServerURL(new URL(
 http://127.0.0.1:8084/adicXmlRpcServer/xmlrpc;));
   } catch (MalformedURLException ex) {
   ex.printStackTrace();
   }
   XmlRpcClient client = new XmlRpcClient();
   client.setConfig(config);
   Object[] params = new Object[] {new String(testDir)};

   try {
   /* OPTION A (next 5 lines):
* This works, but looks ugly. Is there a better way to receive
* an ArrayList of strings from the xml-rpc server?
*/
   Object[] result = (Object[]) client.execute(DirList.ls,
 params);
   ArrayListString dirListing = new ArrayListString();
   for (Object o : result) {
   dirListing.add(o.toString());
   }

   /* OPTION B (next 2 lines):
* This doesn't work, but is the way I would like the code to
* work. Java runtime doesn't like the cast.
*/
 //ArrayListString dirListing =
 //(ArrayListString) client.execute(DirList.ls,
 params);

   System.out.println(Listing Length= + dirListing.size());
   System.out.println(  First 10:);
   for (int i = 0; i  10; i++) {
   System.out.println( + dirListing.get(i));
   }
   } catch (XmlRpcException ex) {
   ex.printStackTrace();
   }
   }
 }

 - End client code listing 

 In case it helps to know the server code, I'm sending an ArrayListString
 at the other end:

 - Begin server code listing 

 /*
 * FILE: DirList.java
 */
 package gov.noaa.eds.adicXmlRpc;

 import java.util.ArrayList;
 import java.util.Random;

 /**
 * Provide directory listing functionality.
 */
 public class DirList {

   /**
* Return a directory listing.
* Currently generates made up names.
* @param dirName directory name for which to get a listing.
* @return a list of filenames for dirName
*/
   public ArrayListString ls(String dirName) {
   Random rng = new Random();
   int listLength = 2000;
   ArrayListString listing = new ArrayListString(listLength);
   for (int i = 0; i  listLength; i++) {
   int filenameLen = 1 + rng.nextInt(40);
   StringBuffer filename = new StringBuffer(sample_);
   for (int f = 0; f  filenameLen; f++) {

 filename.append(abcdefghijklmnopqrstuvwxyz.charAt(rng.nextInt(26)));
   }
   listing.add(filename.toString());
   }
   return listing;
   }
 }

 - End server code listing 

 If anyone wants I can also post the XmlRpcServlet.properties, web.xml or
 maven pom.xml files, but those probably aren't needed.



Re: Renaming XML RPC functions

2009-04-23 Thread Stanislav Miklik
Hi,

it is also possible to change on server side (if you want). You can define
your own request handling where you can implement mapping between xml rpc
calls and your code as you want. But maybe it would be easier to change the
client ;-)
see api:

XmlRpcServer :

public void *setHandlerMapping*(XmlRpcHandlerMapping
http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/server/XmlRpcHandlerMapping.html
pMapping)

XmlRpcHandler:

java.lang.Object *execute*(XmlRpcRequest
http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/XmlRpcRequest.html
pRequest)


Regards
Stano

On Thu, Apr 23, 2009 at 08:39, Markus Meyer me...@mesw.de wrote:

 James,

 thanks for answering. The simple reason is that the interface was defined
 like this. The client has already been written but the server has not. If
 this would not be possible, the interface definition would need to be
 adjusted and the client changed. The client is written in Python and with
 the xmlrpclib module in Python there is no such limitation.


 Markus

 James Dumay schrieb:

  Oh sorry, I didn't read this correctly (thats what you get for emailing
 when your up late).

 I don't think thats possible - any particular reason this is needed?

 James

 - Original Message -
 From: Markus Meyer me...@mesw.de
 To: xmlrpc-dev@ws.apache.org
 Sent: Wednesday, April 22, 2009 10:21:46 PM GMT +10:00 Canberra /
 Melbourne / Sydney
 Subject: Renaming XML RPC functions

 Hi everyone,

 can I rename XML-RPC functions so they appear without the class name? For
 example, to execute the add function in the Calculator class from the
 tutorial, a XML-RPC client has to call Calculator.add instead of just
 add. I need to implement a server which uses function names without the
 class name. Can I change this so the client only has to call add?

 Thanks in advance!

 Regards
 Markus







Re: Multiple xmlrpc calls over single connection

2009-01-14 Thread Stanislav Miklik
yes, I have similar experiences with xmlrpc-2.x with using
XmlRpcLiteClient. This client for every request creates new transport
class, ie. new connection was created every time. Therefore I have to
create my new implementation :

public class LiteClient extends XmlRpcClientLite {

   private XmlRpcTransport transport = null;

   public LiteClient(URL url) {
  super(url);
   }

   @Override
   protected XmlRpcTransport createTransport() {
  if (transport == null) {
 transport = new LiteTransport(this.url);
  }
  return transport;
   }

}

But I am not sure if this is the case also for you.

Regards
Stano

On Wed, Jan 14, 2009 at 21:33, Craig Kelley namo...@gmail.com wrote:
 With Apache xmlrpc-1, each xmlrpc call corresponds with a new TCP
 connection -- even if its using http/1.1 and keepalive.

 On Wed, Jan 14, 2009 at 11:15 AM, Mike Boyers mboy...@yahoo.com wrote:
 I'm not sure if this helps with the discussion or not, but here goes.

 I haven't paid much attention to what happens when using httpclient within 
 the xmlrpc framework, but around the days of httpclient v2.0, I used it 
 extensively in a standalone fashion.  I did look at version 3.0 as well, but 
 haven't looked at anything since.  But I assume what applied then will still 
 apply now.

 Anyway, I can confirm that the httpclient framework itself supports 
 keep-alives.  I used WireShark (which was named Ethereal at the time) and 
 paid pretty close attention to how it behaved.  If I remember right, it has 
 a couple small idiosyncracies, like not being able to close it's side of a 
 connection at the instant that the remote side closes it, but they had 
 workarounds for this type of thing that prevented errors.  If I remember 
 right, it would close it's side of the connection immediately before firing 
 off the next transaction.  This particular behavior may be corrected now.

 I ended up using httpclient it for my project and it performed well.  I used 
 it under pretty load, about 100k requests an hour and didn't run into any 
 real issues.

 I do remember that in order to enable keep-alives, the configuration was 
 slightly different from the most basic configuration, but it was still very 
 simple.

 I had hoped to have a little more time to mess around with this within the 
 framework of ws-xmlrpc and report results and give an example, but I just 
 haven't been able to make the time.

 -Mike







 --
 http://inconnu.islug.org/~ink finger i...@inconnu.islug.org for PGP block



Re: RPC With A Dynamic Number of Variables

2008-07-15 Thread Stanislav Miklik
Hi,

If I have understood it correctly, there is no problem with such methods.

Here is example from the site:
Object[] params = new Object[]{new Integer(33), new Integer(9)};
Integer result = (Integer) client.execute(Calculator.add, params);

Also execute method takes parameters in the Object[] object. And then
this array object is translated to XML RPC as param1, param2, ...
paramX  (not one parameter of array type!). And that is exactly what
you want, isn't it?

BR
Stano

On Tue, Jul 15, 2008 at 17:15, Elam Daly [EMAIL PROTECTED] wrote:
 I agree Jochen, but this is the client's already implemented specification
 and I don't have control over changing it at this point.

 Browsing the archives, it seems that a Filter is not the best choice to
 correct this though.

 - Elam


 On Tue, Jul 15, 2008 at 11:11 AM, Jochen Wiedmann [EMAIL PROTECTED]
 wrote:

 On Tue, Jul 15, 2008 at 3:51 PM, Elam Daly [EMAIL PROTECTED] wrote:

  We have a client who is expecting us to create an XML-RPC service with a
  dynamic number of variables, ie myRPC(var_1,var_2, var_x);
 
  Considering the static nature of the ws-xmlrpc library, I don't see how I
  can achieve this without using a Filter or something similar.

 Why not simply using an Object[] or a List?

 Jochen

 --
 Look, that's why there's rules, understand? So that you think before
 you break 'em.

  -- (Terry Pratchett, Thief of Time)




Re: RPC With A Dynamic Number of Variables

2008-07-15 Thread Stanislav Miklik
Hi *,

sorry, I read it to quickly (I assumed that server is fixed, not the
client) ;-) As Craig said, there is a solution with making your own
handler and then from XmlRpcRequest you can get any number of
parameters.

Check eg.
http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/server/XmlRpcServer.html#setHandlerMapping(org.apache.xmlrpc.server.XmlRpcHandlerMapping)
http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/XmlRpcRequest.html

Stano

On Tue, Jul 15, 2008 at 17:44, Craig Kelley [EMAIL PROTECTED] wrote:
 Hi Elam,

 I'm not certain about XMLRPC 3.x, but with 1.x you could override the
 execute() method for XmlRpcHandler and do this sort of thing.  We use
 it along with introspection to route calls to various places.

  -Craig

 On Tue, Jul 15, 2008 at 9:39 AM, Elam Daly [EMAIL PROTECTED] wrote:
 Jochen,

 just so I'm clear, are you suggesting to change my current method signature
 from myRPC(var_1, var_2, var_x) to myRPC(Object[] obja) and then parse the
 array and forward to the appropriate method?

 Stano,

 The client is using PHP and when they try and execute my RPC, they get an
 error claiming the method doesn't exist because there isn't one matching the
 method signature that they are trying to use.

 If I call the calculator RPC with Object[] params = new Object[]{new
 Integer(33), new Integer(9), new Integer(10)};. afaik that won't work
 because the add method is only expecting 2 parameters, not 3.

 --
 http://inconnu.islug.org/~ink finger [EMAIL PROTECTED] for PGP block



Re: hi...problem with xml rpc java and tomcat

2008-04-14 Thread Stanislav Miklik
Hi *,

generic types are not problem for XML RPC since collection are not generic
at runtime (ie. this is only compile time check, however some compile time
warning you will get).

Normally you have no problem to cast return values as they are mapped as
described in API docs. But with XML RPC arrays there are two possibilities
List and Object[] and there is no contract by the docs what exactly is the
return value (Jochen probably knows that always Object[], but since it is
not described...) I am using solution described in:
http://www.nabble.com/Are-there-any-examples-of-clients-loading-parameters-for-structs-or-arrays--to16455615.html
(see the reply)

Regards
Stano


On Mon, Apr 14, 2008 at 11:35 AM, Prasad kadbane [EMAIL PROTECTED]
wrote:

 Hi,

   XML-RPC uses its own serialization classes to serialize object, if
 you check
 org.apache.xmlrpc.serializer package in API docs you will come to know
 that
 there are serializer classes for most of parameter types such as MAP, List
 etc.
 The map you are using may not be supported by xmlrpc but it does support
 the
 older map ie

 Map result = client.execute(Open.OpenEnvironment1,params);

 above code shld work and further when you get map just iterate that map
 and
 then try to typecast map value to List.

 because list object is supported by xml-rpc.


 On Mon, Apr 14, 2008 at 4:35 AM, eejimkos [EMAIL PROTECTED] wrote:

 
  first,tnks for your time..
 
  im my client i have a servlet which sends(ans receives the xml
  response-request).the data that i send is simply 2 strings and i want
  to take back from my server HashMapString, ListString.
  i do that:
 
  
  HashMapString,ListString result= new HashMapString,ListString;
 
  
  Object[] params = new Object[]{new String(x1), new String(x2)};
 
  try {
  result=
  (HashMapString,ListString)client.execute(Open.OpenEnvironment1,
  params);
 
  the problem is here...i can't cast to see my response since i use
  jdk6,i have to use generics??collection??any advise??
  --
  View this message in context:
 
 http://www.nabble.com/hi...problem-with-xml-rpc-java-and-tomcat-tp16669185p16669185.html
  Sent from the Apache Xml-RPC - Dev mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


 --
 Prasad C. Kadbane.

 Software Engineer;
 SunGard Offshore Services(India)
 Sr.No. 108/8/1 + 2/1, S.B Road, Pune 411 053, India;
 Tel +91-20-25606000 Extn. 6117; Fax +91 20 2560 6222;
 Mobile No : 9850010620



[PATCH] Faq: ClassCastException

2008-04-14 Thread Stanislav Miklik
Hi Jochen,

here is my first patch ;-) I think the cast in the faq would cause
ClassCastException and should be omitted.

Regards
Stano
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: XmlRpcClient persistent connections

2007-06-29 Thread Stanislav Miklik

Hi,

I think you can manage createTransport of the client always to return
transport that will keep only one connection.
I am using something like that but I am using the old (2.xxx) version of XML
RPC and LiteTransport with keep-alive, but I assume that something like that
is possible also in the new one.

Regards
Stano

On 6/29/07, Don Montealegre [EMAIL PROTECTED] wrote:


greetings ,

is there a way to just open and use 1 connection using XmlRpcClient
and just pass multiple request to it? tnx


Bug in xml-rpc rc1

2006-08-02 Thread Stanislav Miklik

Hello,

I have probably found a bug in WebServer.shutdown().
This call has frozen, but I don't know why.
Conditions that might affecting this:
1. I started the server with enabled extensions and enabled keepalive
(others default, if not mentioned)
2. In the same program (in another thread of course) I create client
connected to this server with enabled extensions
3. this client sends in loop requests to server (delayed for 2 seconds)
4. then I called shutdown on the server (e.g. after 10 seconds)

When I try to debug it, my debugger (Eclipse) freeze on command
pool.shutdown(); in method shutdown().

Hopefully this description will help.

Bye

Stano


Bug in xmlrpc-3.0b1

2006-07-31 Thread Stanislav Miklik

Hello,

I think I found bug in xmlrpc-3.0b1. Maybe it is corrected now, but also in
rc1 it was the same. I can't find the way to report this bug, also I write
email to you.
Bug - more correctly:

class:  org.apache.xmlrpc.webserver.WebServer

method *

private
**synchronized* *void* setupServerSocket( *int* backlog) *throws*IOException
*{*

// Since we can't reliably set SO_REUSEADDR until JDK 1.4 is

// the standard, try to (re-)open the server socket several

// times. Some OSes (Linux and Solaris, for example), hold on

// to listener sockets for a brief period of time for security

// reasons before relinquishing their hold.

*for* (*int* i = 1; ; i++) {

*try* {

serverSocket = createServerSocket(port, backlog, address);

// A socket timeout must be set.

*if* (serverSocket.getSoTimeout() = 0) {

serverSocket.setSoTimeout(4096);

}

*return*;

}
*catch* (BindException e) {

*if* (i == 10) {

*throw* e;

}
*else* {

*long* waitUntil = System.currentTimeMillis();

*for* (;;) {

*long* l = waitUntil - System.currentTimeMillis();

*if* (l  0) {

*try* {

Thread.sleep(l);

}
*catch* (InterruptedException ex) {

}

}

}

}

}

}

}



Selected text seems to me like neverending cycle. I don't see the way out
and also variable l is always l=0.



Bye, hopefully it is not problem to correct it.

Stano.