/**
- * gras_socket_server_ext:
- *
- * Opens a server socket and make it ready to be listened to.
- * In real life, you'll get a TCP socket.
+ * @brief Opens a server socket and makes it ready to be listened to.
+ * @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)
+ *
+ * In real life, you'll get a TCP socket.
*/
gras_socket_t
gras_socket_server_ext(unsigned short port,
- unsigned long int bufSize,
+ unsigned long int buf_size,
int measurement) {
xbt_ex_t e;
gras_trp_socket_new(1,&sock);
sock->plugin= trp;
sock->port=port;
- sock->bufSize = bufSize;
+ sock->buf_size = buf_size>0 ? buf_size : 32*1024;
sock->meas = measurement;
/* Call plugin socket creation function */
}
/**
- * gras_socket_client_ext:
- *
- * Opens a client socket to a remote host.
- * In real life, you'll get a TCP socket.
+ * @brief Opens a client socket to a remote host.
+ * @param buf_size: size of the buffer (in bytes) on the socket (for TCP sockets only). If 0, a sain default is used (32k, but may change)
+ *
+ * In real life, you'll get a TCP socket.
*/
gras_socket_t
gras_socket_client_ext(const char *host,
unsigned short port,
- unsigned long int bufSize,
+ unsigned long int buf_size,
int measurement) {
xbt_ex_t e;
sock->plugin= trp;
sock->peer_port = port;
sock->peer_name = (char*)strdup(host?host:"localhost");
- sock->bufSize = bufSize;
+ sock->buf_size = buf_size>0 ? buf_size: 32*1024;
sock->meas = measurement;
/* plugin-specific */
struct sockaddr_in addr;
struct hostent *he;
struct in_addr *haddr;
- int size = sock->bufSize * 1024;
+ int size = sock->buf_size;
sock->incoming = 1; /* TCP sockets are duplex'ed */
*/
static inline void gras_trp_sock_socket_server(gras_trp_plugin_t ignored,
gras_socket_t sock){
- int size = sock->bufSize * 1024;
+ int size = sock->buf_size;
int on = 1;
struct sockaddr_in server;
THROW1(system_error,0,"setsockopt failed, cannot condition the socket: %s",
sock_errstr);
- res->bufSize = sock->bufSize;
- size = sock->bufSize * 1024;
+ res->buf_size = sock->buf_size;
+ size = sock->buf_size;
if (setsockopt(sd, SOL_SOCKET, SO_RCVBUF, (char *)&size, sizeof(size))
|| setsockopt(sd, SOL_SOCKET, SO_SNDBUF, (char *)&size, sizeof(size)))
WARN1("setsockopt failed, cannot set buffer size: %s", sock_errstr);