+/**
+ * @brief Opens a server socket on any port in the given range
+ *
+ * @param minport: first port we will try
+ * @param maxport: last port we will try
+ * @param buf_size: size of the buffer (in byte) on the socket (for TCP sockets only). If 0, a sain default is used (32k, but may change)
+ * @param measurement: whether this socket is meant to convey measurement (if you don't know, use 0 to exchange regular messages)
+ *
+ * If none of the provided ports works, raises the exception got when trying the last possibility
+ */
+gras_socket_t
+gras_socket_server_range(unsigned short minport, unsigned short maxport,
+ unsigned long int buf_size, int measurement) {
+
+ int port;
+ gras_socket_t res=NULL;
+ xbt_ex_t e;
+
+ for (port=minport; port<maxport;port ++) {
+ TRY {
+ res=gras_socket_server_ext(port,buf_size,measurement);
+ } CATCH(e) {
+ if (port==maxport)
+ RETHROW;
+ xbt_ex_free(e);
+ }
+ if (res)
+ return res;
+ }
+ THROW_IMPOSSIBLE;
+}