# network handler
[utilities]

## Functions
AXIS2_EXTERN axis2_socket_t | axutil_network_handler_open_socket (const axutil_env_t *env, char *server, int port)
AXIS2_EXTERN axis2_socket_t | axutil_network_handler_create_server_socket (const axutil_env_t *env, int port)
AXIS2_EXTERN axis2_status_t | axutil_network_handler_close_socket (const axutil_env_t *env, axis2_socket_t socket)
AXIS2_EXTERN axis2_status_t | axutil_network_handler_set_sock_option (const axutil_env_t *env, axis2_socket_t socket, int option, int value)
AXIS2_EXTERN axis2_socket_t | axutil_network_handler_svr_socket_accept (const axutil_env_t *env, axis2_socket_t socket)
AXIS2_EXTERN axis2_char_t * | axutil_network_handler_get_svr_ip (const axutil_env_t *env, axis2_socket_t socket)
AXIS2_EXTERN axis2_char_t * | axutil_network_handler_get_peer_ip (const axutil_env_t *env, axis2_socket_t socket)
AXIS2_EXTERN axis2_socket_t | axutil_network_handler_open_dgram_socket (const axutil_env_t *env)
AXIS2_EXTERN axis2_status_t | axutil_network_handler_send_dgram (const axutil_env_t *env, axis2_socket_t socket, axis2_char_t *buff, int *buf_len, axis2_char_t *addr, int dest_port, int *source_port)
AXIS2_EXTERN axis2_status_t | axutil_network_handler_read_dgram (const axutil_env_t *env, axis2_socket_t socket, axis2_char_t *buffer, int *buf_len, axis2_char_t **addr, int *port)
AXIS2_EXTERN axis2_socket_t | axutil_network_handler_create_dgram_svr_socket (const axutil_env_t *env, int port)
AXIS2_EXTERN axis2_status_t | axutil_network_handler_bind_socket (const axutil_env_t *env, axis2_socket_t sock, int port)
AXIS2_EXTERN axis2_socket_t | axutil_network_hadler_create_multicast_svr_socket (const axutil_env_t *env, int port, axis2_char_t *mul_addr)

## Function Documentation

AXIS2_EXTERN axis2_status_t axutil_network_handler_close_socket | ( | const axutil_env_t * | env,
|  | axis2_socket_t | socket |
| ) |  |  |

closes a socket

Parameters:

  | opened | socket that need to be closed

Returns:
  status code

AXIS2_EXTERN axis2_socket_t axutil_network_handler_create_server_socket | ( | const axutil_env_t * | env,
|  | int | port |
| ) |  |  |

creates a server socket for a given port

Parameters:

  | port | port of the socket to be bound

Returns:
  creates server socket

AXIS2_EXTERN axis2_char_t* axutil_network_handler_get_svr_ip | ( | const axutil_env_t * | env,
|  | axis2_socket_t | socket |
| ) |  |  |

Returns the ip address of the server associated with the socket

Parameters:

  | socket | valid socket (obtained by accept() or similar call)

Returns:
  ip address asoociated with the socket or NULL

AXIS2_EXTERN axis2_socket_t axutil_network_handler_open_socket | ( | const axutil_env_t * | env,
|  | char * | server,
|  | int | port |
| ) |  |  |

open a socket for a given server

Parameters:

  | server | ip address or the fqn of the server
  | port | port of the service

Returns:
  opened socket

AXIS2_EXTERN axis2_status_t axutil_network_handler_set_sock_option | ( | const axutil_env_t * | env,
|  | axis2_socket_t | socket,
|  | int | option,
|  | int | value |
| ) |  |  |

used to set up socket options such as timeouts, non-blocking ..etc

Parameters:

  | socket | valid socket (obtained by socket() or similar call)
  | option | the name of the option
  | value | Value to be set

Returns:
  status of the operations as axis2_status_t

AXIS2_EXTERN axis2_socket_t axutil_network_handler_svr_socket_accept | ( | const axutil_env_t * | env,
|  | axis2_socket_t | socket |
| ) |  |  |

Accepts remote connections for a server socket

Parameters:

  | socket | valid server socket (obtained by socket() or similar call)

Returns:
  created socket to handle the incoming client connection