FreeSWITCH API Documentation  1.7.0
Modules | Macros | Typedefs | Enumerations | Functions
Network Routines
+ Collaboration diagram for Network Routines:

Modules

 IP Protocol Definitions for use when creating sockets
 

Macros

#define SWITCH_SO_LINGER   1
 
#define SWITCH_SO_KEEPALIVE   2
 
#define SWITCH_SO_DEBUG   4
 
#define SWITCH_SO_NONBLOCK   8
 
#define SWITCH_SO_REUSEADDR   16
 
#define SWITCH_SO_SNDBUF   64
 
#define SWITCH_SO_RCVBUF   128
 
#define SWITCH_SO_DISCONNECTED   256
 
#define SWITCH_SO_TCP_NODELAY   512
 
#define SWITCH_SO_TCP_KEEPIDLE   520
 
#define SWITCH_SO_TCP_KEEPINTVL   530
 
#define SWITCH_INET   AF_INET
 
#define SWITCH_INET6   0
 
#define SWITCH_UNSPEC   0
 

Typedefs

typedef struct apr_socket_t switch_socket_t
 
typedef struct apr_sockaddr_t switch_sockaddr_t
 

Enumerations

enum  switch_shutdown_how_e { SWITCH_SHUTDOWN_READ, SWITCH_SHUTDOWN_WRITE, SWITCH_SHUTDOWN_READWRITE }
 

Functions

switch_status_t switch_socket_create (switch_socket_t **new_sock, int family, int type, int protocol, switch_memory_pool_t *pool)
 
switch_status_t switch_socket_shutdown (switch_socket_t *sock, switch_shutdown_how_e how)
 
switch_status_t switch_socket_close (switch_socket_t *sock)
 
switch_status_t switch_socket_bind (switch_socket_t *sock, switch_sockaddr_t *sa)
 
switch_status_t switch_socket_listen (switch_socket_t *sock, int32_t backlog)
 
switch_status_t switch_socket_accept (switch_socket_t **new_sock, switch_socket_t *sock, switch_memory_pool_t *pool)
 
switch_status_t switch_socket_connect (switch_socket_t *sock, switch_sockaddr_t *sa)
 
int switch_socket_fd_get (switch_socket_t *sock)
 
uint16_t switch_sockaddr_get_port (switch_sockaddr_t *sa)
 
const char * switch_get_addr (char *buf, switch_size_t len, switch_sockaddr_t *in)
 
switch_status_t switch_getnameinfo (char **hostname, switch_sockaddr_t *sa, int32_t flags)
 
int32_t switch_sockaddr_get_family (switch_sockaddr_t *sa)
 
switch_status_t switch_sockaddr_ip_get (char **addr, switch_sockaddr_t *sa)
 
int switch_sockaddr_equal (const switch_sockaddr_t *sa1, const switch_sockaddr_t *sa2)
 
switch_status_t switch_sockaddr_info_get (switch_sockaddr_t **sa, const char *hostname, int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool)
 
switch_status_t switch_sockaddr_create (switch_sockaddr_t **sa, switch_memory_pool_t *pool)
 
switch_status_t switch_socket_send (switch_socket_t *sock, const char *buf, switch_size_t *len)
 
switch_status_t switch_socket_sendto (switch_socket_t *sock, switch_sockaddr_t *where, int32_t flags, const char *buf, switch_size_t *len)
 
switch_status_t switch_socket_send_nonblock (switch_socket_t *sock, const char *buf, switch_size_t *len)
 
switch_status_t switch_socket_recvfrom (switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, size_t *len)
 
switch_status_t switch_socket_atmark (switch_socket_t *sock, int *atmark)
 
switch_status_t switch_socket_recv (switch_socket_t *sock, char *buf, switch_size_t *len)
 
switch_status_t switch_socket_opt_set (switch_socket_t *sock, int32_t opt, int32_t on)
 
switch_status_t switch_socket_timeout_set (switch_socket_t *sock, switch_interval_time_t t)
 
switch_status_t switch_mcast_join (switch_socket_t *sock, switch_sockaddr_t *join, switch_sockaddr_t *iface, switch_sockaddr_t *source)
 
switch_status_t switch_mcast_hops (switch_socket_t *sock, uint8_t ttl)
 
switch_status_t switch_mcast_loopback (switch_socket_t *sock, uint8_t opt)
 
switch_status_t switch_mcast_interface (switch_socket_t *sock, switch_sockaddr_t *iface)
 

Detailed Description

Macro Definition Documentation

#define SWITCH_INET   AF_INET

Not all platforms have these defined, so we'll define them here The default values come from FreeBSD 4.1.1

Definition at line 1009 of file switch_apr.h.

#define SWITCH_INET6   0

Definition at line 1013 of file switch_apr.h.

#define SWITCH_SO_DEBUG   4

Definition at line 993 of file switch_apr.h.

#define SWITCH_SO_DISCONNECTED   256

Definition at line 998 of file switch_apr.h.

#define SWITCH_SO_KEEPALIVE   2

Definition at line 992 of file switch_apr.h.

#define SWITCH_SO_LINGER   1

Definition at line 991 of file switch_apr.h.

#define SWITCH_SO_NONBLOCK   8
#define SWITCH_SO_RCVBUF   128

Definition at line 997 of file switch_apr.h.

Referenced by switch_rtp_set_local_address().

#define SWITCH_SO_REUSEADDR   16
#define SWITCH_SO_SNDBUF   64

Definition at line 996 of file switch_apr.h.

Referenced by switch_rtp_set_local_address().

#define SWITCH_SO_TCP_KEEPIDLE   520

Definition at line 1000 of file switch_apr.h.

Referenced by switch_socket_opt_set().

#define SWITCH_SO_TCP_KEEPINTVL   530

Definition at line 1001 of file switch_apr.h.

Referenced by switch_socket_opt_set().

#define SWITCH_SO_TCP_NODELAY   512

Definition at line 999 of file switch_apr.h.

#define SWITCH_UNSPEC   0

Typedef Documentation

typedef struct apr_sockaddr_t switch_sockaddr_t

Freeswitch's socket address type, used to ensure protocol independence

Definition at line 1029 of file switch_apr.h.

typedef struct apr_socket_t switch_socket_t

A structure to represent sockets

Definition at line 1026 of file switch_apr.h.

Enumeration Type Documentation

Enumerator
SWITCH_SHUTDOWN_READ 

no longer allow read request

SWITCH_SHUTDOWN_WRITE 

no longer allow write requests

SWITCH_SHUTDOWN_READWRITE 

no longer allow read or write requests

Definition at line 1031 of file switch_apr.h.

1274  {

Function Documentation

const char* switch_get_addr ( char *  buf,
switch_size_t  len,
switch_sockaddr_t in 
)

Definition at line 894 of file switch_apr.c.

References buf, get_addr(), get_addr6(), memset(), and SWITCH_BLANK_STRING.

Referenced by check_rtcp_and_ice(), enable_local_rtcp_socket(), enable_remote_rtcp_socket(), handle_ice(), handle_nack(), read_rtp_packet(), rtp_common_read(), rtp_common_write(), switch_print_host(), switch_rtp_activate_ice(), and switch_stun_host_lookup().

895 {
896  if (!in) {
897  return SWITCH_BLANK_STRING;
898  }
899 
900  memset(buf, 0, len);
901 
902  if (in->family == AF_INET) {
903  get_addr(buf, len, (struct sockaddr *) &in->sa, in->salen);
904  return buf;
905  }
906 
907  get_addr6(buf, len, (struct sockaddr_in6 *) &in->sa, in->salen);
908  return buf;
909 }
switch_byte_t switch_byte_t * buf
switch_byte_t in
#define SWITCH_BLANK_STRING
Definition: switch_types.h:47
char * get_addr(char *buf, switch_size_t len, struct sockaddr *sa, socklen_t salen)
find the char representation of an ip adress
char * get_addr6(char *buf, switch_size_t len, struct sockaddr_in6 *sa, socklen_t salen)
memset(buf, 0, buflen)
switch_status_t switch_getnameinfo ( char **  hostname,
switch_sockaddr_t sa,
int32_t  flags 
)

Definition at line 926 of file switch_apr.c.

927 {
928  return apr_getnameinfo(hostname, sa, flags);
929 }
switch_status_t switch_mcast_hops ( switch_socket_t sock,
uint8_t  ttl 
)

Set the Multicast Time to Live (ttl) for a multicast transmission.

Parameters
sockThe socket to set the multicast ttl
ttlTime to live to Assign. 0-255, default=1
Remarks
If the TTL is 0, packets will only be seen by sockets on the local machine, and only when multicast loopback is enabled.

Definition at line 876 of file switch_apr.c.

Referenced by switch_rtp_set_local_address().

877 {
878  return apr_mcast_hops(sock, ttl);
879 }
switch_status_t switch_mcast_interface ( switch_socket_t sock,
switch_sockaddr_t iface 
)

Definition at line 886 of file switch_apr.c.

Referenced by switch_rtp_set_local_address().

887 {
888  return apr_mcast_interface(sock, iface);
889 }
switch_status_t switch_mcast_join ( switch_socket_t sock,
switch_sockaddr_t join,
switch_sockaddr_t iface,
switch_sockaddr_t source 
)

Join a Multicast Group

Parameters
sockThe socket to join a multicast group
joinThe address of the multicast group to join
ifaceAddress of the interface to use. If NULL is passed, the default multicast interface will be used. (OS Dependent)
sourceSource Address to accept transmissions from (non-NULL implies Source-Specific Multicast)

Definition at line 871 of file switch_apr.c.

Referenced by init_nat_monitor(), and switch_rtp_set_local_address().

872 {
873  return apr_mcast_join(sock, join, iface, source);
874 }
switch_status_t switch_mcast_loopback ( switch_socket_t sock,
uint8_t  opt 
)

Definition at line 881 of file switch_apr.c.

882 {
883  return apr_mcast_loopback(sock, opt);
884 }
switch_status_t switch_sockaddr_create ( switch_sockaddr_t **  sa,
switch_memory_pool_t pool 
)

Definition at line 795 of file switch_apr.c.

References memset(), pool, switch_assert, and SWITCH_STATUS_SUCCESS.

Referenced by switch_rtp_create().

796 {
797  switch_sockaddr_t *new_sa;
798  unsigned short family = APR_INET;
799 
800  new_sa = apr_pcalloc(pool, sizeof(apr_sockaddr_t));
801  switch_assert(new_sa);
802  new_sa->pool = pool;
803  memset(new_sa, 0, sizeof(*new_sa));
804 
805  new_sa->family = family;
806  new_sa->sa.sin.sin_family = family;
807 
808  new_sa->salen = sizeof(struct sockaddr_in);
809  new_sa->addr_str_len = 16;
810  new_sa->ipaddr_ptr = &(new_sa->sa.sin.sin_addr);
811  new_sa->ipaddr_len = sizeof(struct in_addr);
812 
813  *sa = new_sa;
814  return SWITCH_STATUS_SUCCESS;
815 }
switch_memory_pool_t * pool
struct apr_sockaddr_t switch_sockaddr_t
Definition: switch_apr.h:1029
#define switch_assert(expr)
memset(buf, 0, buflen)
int switch_sockaddr_equal ( const switch_sockaddr_t sa1,
const switch_sockaddr_t sa2 
)

Definition at line 866 of file switch_apr.c.

867 {
868  return apr_sockaddr_equal(sa1, sa2);
869 }
int32_t switch_sockaddr_get_family ( switch_sockaddr_t sa)

Definition at line 921 of file switch_apr.c.

Referenced by enable_local_rtcp_socket(), enable_remote_rtcp_socket(), switch_rtp_set_local_address(), and switch_rtp_set_remote_address().

922 {
923  return sa->family;
924 }
uint16_t switch_sockaddr_get_port ( switch_sockaddr_t sa)
switch_status_t switch_sockaddr_info_get ( switch_sockaddr_t **  sa,
const char *  hostname,
int32_t  family,
switch_port_t  port,
int32_t  flags,
switch_memory_pool_t pool 
)

Create apr_sockaddr_t from hostname, address family, and port.

Parameters
saThe new apr_sockaddr_t.
hostnameThe hostname or numeric address string to resolve/parse, or NULL to build an address that corresponds to 0.0.0.0 or ::
familyThe address family to use, or SWITCH_UNSPEC if the system should decide.
portThe port number.
flagsSpecial processing flags:
      APR_IPV4_ADDR_OK          first query for IPv4 addresses; only look
                                for IPv6 addresses if the first query failed;
                                only valid if family is APR_UNSPEC and hostname
                                isn't NULL; mutually exclusive with
                                APR_IPV6_ADDR_OK
      APR_IPV6_ADDR_OK          first query for IPv6 addresses; only look
                                for IPv4 addresses if the first query failed;
                                only valid if family is APR_UNSPEC and hostname
                                isn't NULL and APR_HAVE_IPV6; mutually exclusive
                                with APR_IPV4_ADDR_OK
poolThe pool for the apr_sockaddr_t and associated storage.

Definition at line 817 of file switch_apr.c.

Referenced by enable_local_rtcp_socket(), enable_remote_rtcp_socket(), handle_ice(), init_nat_monitor(), switch_ivr_activate_unicast(), switch_rtp_activate_ice(), switch_rtp_activate_rtcp(), switch_rtp_set_local_address(), switch_rtp_set_remote_address(), switch_stun_host_lookup(), switch_stun_lookup(), and test_port().

819 {
820  return apr_sockaddr_info_get(sa, hostname, family, port, flags, pool);
821 }
switch_memory_pool_t * pool
switch_status_t switch_sockaddr_ip_get ( char **  addr,
switch_sockaddr_t sa 
)

Definition at line 861 of file switch_apr.c.

862 {
863  return apr_sockaddr_ip_get(addr, sa);
864 }
switch_status_t switch_socket_accept ( switch_socket_t **  new_sock,
switch_socket_t sock,
switch_memory_pool_t pool 
)

Accept a new connection request

Parameters
new_sockA copy of the socket that is connected to the socket that made the connection request. This is the socket which should be used for all future communication.
sockThe socket we are listening on.
poolThe pool for the new socket.

Definition at line 729 of file switch_apr.c.

730 {
731  return apr_socket_accept(new_sock, sock, pool);
732 }
switch_memory_pool_t * pool
switch_status_t switch_socket_atmark ( switch_socket_t sock,
int *  atmark 
)

Definition at line 931 of file switch_apr.c.

932 {
933  return apr_socket_atmark(sock, atmark);
934 }
switch_status_t switch_socket_bind ( switch_socket_t sock,
switch_sockaddr_t sa 
)

Bind the socket to its associated port

Parameters
sockThe socket to bind
saThe socket address to bind to
Remarks
This may be where we will find out if there is any other process using the selected port.

Definition at line 719 of file switch_apr.c.

Referenced by enable_local_rtcp_socket(), init_nat_monitor(), switch_ivr_activate_unicast(), switch_rtp_set_local_address(), switch_stun_lookup(), and test_port().

720 {
721  return apr_socket_bind(sock, sa);
722 }
switch_status_t switch_socket_close ( switch_socket_t sock)

Close a socket.

Parameters
sockThe socket to close

Definition at line 714 of file switch_apr.c.

Referenced by enable_local_rtcp_socket(), enable_remote_rtcp_socket(), init_nat_monitor(), switch_ivr_deactivate_unicast(), switch_rtp_destroy(), switch_rtp_set_local_address(), switch_rtp_set_remote_address(), switch_rtp_udptl_mode(), switch_stun_lookup(), and test_port().

715 {
716  return apr_socket_close(sock);
717 }
switch_status_t switch_socket_connect ( switch_socket_t sock,
switch_sockaddr_t sa 
)

Issue a connection request to a socket either on the same machine or a different one.

Parameters
sockThe socket we wish to use for our side of the connection
saThe address of the machine we wish to connect to.

Definition at line 734 of file switch_apr.c.

735 {
736  return apr_socket_connect(sock, sa);
737 }
switch_status_t switch_socket_create ( switch_socket_t **  new_sock,
int  family,
int  type,
int  protocol,
switch_memory_pool_t pool 
)

Create a socket.

Parameters
new_sockThe new socket that has been set up.
familyThe address family of the socket (e.g., SWITCH_INET).
typeThe type of the socket (e.g., SOCK_STREAM).
protocolThe protocol of the socket (e.g., SWITCH_PROTO_TCP).
poolThe pool to use

Definition at line 704 of file switch_apr.c.

Referenced by enable_local_rtcp_socket(), enable_remote_rtcp_socket(), init_nat_monitor(), switch_ivr_activate_unicast(), switch_rtp_set_local_address(), switch_rtp_set_remote_address(), switch_stun_lookup(), and test_port().

705 {
706  return apr_socket_create(new_sock, family, type, protocol, pool);
707 }
switch_memory_pool_t * pool
int switch_socket_fd_get ( switch_socket_t sock)

Get socket fd for the switch socket passed

Parameters
sockThe socket we wish to have fd

Definition at line 911 of file switch_apr.c.

912 {
913  return apr_socket_fd_get(sock);
914 }
switch_status_t switch_socket_listen ( switch_socket_t sock,
int32_t  backlog 
)

Listen to a bound socket for connections.

Parameters
sockThe socket to listen on
backlogThe number of outstanding connections allowed in the sockets listen queue. If this value is less than zero, the listen queue size is set to zero.

Definition at line 724 of file switch_apr.c.

725 {
726  return apr_socket_listen(sock, backlog);
727 }
switch_status_t switch_socket_opt_set ( switch_socket_t sock,
int32_t  opt,
int32_t  on 
)

Setup socket options for the specified socket

Parameters
sockThe socket to set up.
optThe option we would like to configure. One of:
           APR_SO_DEBUG      --  turn on debugging information 
           APR_SO_KEEPALIVE  --  keep connections active
           APR_SO_LINGER     --  lingers on close if data is present
           APR_SO_NONBLOCK   --  Turns blocking on/off for socket
                                 When this option is enabled, use
                                 the APR_STATUS_IS_EAGAIN() macro to
                                 see if a send or receive function
                                 could not transfer data without
                                 blocking.
           APR_SO_REUSEADDR  --  The rules used in validating addresses
                                 supplied to bind should allow reuse
                                 of local addresses.
           APR_SO_SNDBUF     --  Set the SendBufferSize
           APR_SO_RCVBUF     --  Set the ReceiveBufferSize
onValue for the option.

Definition at line 823 of file switch_apr.c.

References SWITCH_SO_TCP_KEEPIDLE, SWITCH_SO_TCP_KEEPINTVL, SWITCH_STATUS_FALSE, SWITCH_STATUS_NOTIMPL, and SWITCH_STATUS_SUCCESS.

Referenced by do_flush(), enable_local_rtcp_socket(), init_nat_monitor(), switch_rtp_clear_flag(), switch_rtp_set_flag(), switch_rtp_set_flags(), switch_rtp_set_local_address(), switch_rtp_udptl_mode(), and switch_stun_lookup().

824 {
825  if (opt == SWITCH_SO_TCP_KEEPIDLE) {
826  int r = -10;
827 
828 #if defined(TCP_KEEPIDLE)
829  r = setsockopt(jsock->client_socket, SOL_TCP, TCP_KEEPIDLE, (void *)&on, sizeof(on));
830 #endif
831  if (r == -10) {
832  return SWITCH_STATUS_NOTIMPL;
833  }
834 
835 
837  }
838 
839  if (opt == SWITCH_SO_TCP_KEEPINTVL) {
840  int r = -10;
841 
842 #if defined(TCP_KEEPINTVL)
843  r = setsockopt(jsock->client_socket, SOL_TCP, TCP_KEEPINTVL, (void *)&on, sizeof(on));
844 #endif
845 
846  if (r == -10) {
847  return SWITCH_STATUS_NOTIMPL;
848  }
849 
851  }
852 
853  return apr_socket_opt_set(sock, opt, on);
854 }
#define SWITCH_SO_TCP_KEEPIDLE
Definition: switch_apr.h:1000
#define SWITCH_SO_TCP_KEEPINTVL
Definition: switch_apr.h:1001
switch_status_t switch_socket_recv ( switch_socket_t sock,
char *  buf,
switch_size_t len 
)

Read data from a network.

Parameters
sockThe socket to read the data from.
bufThe buffer to store the data in.
lenOn entry, the number of bytes to receive; on exit, the number of bytes received.
Remarks
This functions acts like a blocking read by default.  To change 
this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
socket option.
The number of bytes actually received is stored in argument 3.

It is possible for both bytes to be received and an APR_EOF or other error to be returned.

APR_EINTR is never returned.

Definition at line 782 of file switch_apr.c.

References SWITCH_STATUS_BREAK.

Referenced by unicast_thread_run().

783 {
784  int r;
785 
786  r = apr_socket_recv(sock, buf, len);
787 
788  if (r == 35 || r == 730035) {
790  }
791 
792  return (switch_status_t)r;
793 }
switch_byte_t switch_byte_t * buf
switch_status_t
Common return values.
switch_status_t switch_socket_recvfrom ( switch_sockaddr_t from,
switch_socket_t sock,
int32_t  flags,
char *  buf,
size_t *  len 
)
Parameters
fromThe apr_sockaddr_t to fill in the recipient info
sockThe socket to use
flagsThe flags to use
bufThe buffer to use
lenThe length of the available buffer

Definition at line 936 of file switch_apr.c.

References SWITCH_STATUS_BREAK, and SWITCH_STATUS_GENERR.

Referenced by do_flush(), read_rtcp_packet(), read_rtp_packet(), switch_nat_multicast_runtime(), switch_rtp_set_local_address(), and switch_stun_lookup().

937 {
938  int r = SWITCH_STATUS_GENERR;
939 
940  if (from && sock && (r = apr_socket_recvfrom(from, sock, flags, buf, len)) == APR_SUCCESS) {
941  from->port = ntohs(from->sa.sin.sin_port);
942  /* from->ipaddr_ptr = &(from->sa.sin.sin_addr);
943  * from->ipaddr_ptr = inet_ntoa(from->sa.sin.sin_addr);
944  */
945  }
946 
947  if (r == 35 || r == 730035) {
949  }
950 
951  return (switch_status_t)r;
952 }
switch_byte_t switch_byte_t * buf
switch_status_t
Common return values.
switch_status_t switch_socket_send ( switch_socket_t sock,
const char *  buf,
switch_size_t len 
)

Send data over a network.

Parameters
sockThe socket to send the data over.
bufThe buffer which contains the data to be sent.
lenOn entry, the number of bytes to send; on exit, the number of bytes sent.
Remarks
This functions acts like a blocking write by default.  To change 
this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
socket option.

It is possible for both bytes to be sent and an error to be returned.

APR_EINTR is never returned.

Definition at line 739 of file switch_apr.c.

References SWITCH_STATUS_BREAK, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_yield.

740 {
741  int status = SWITCH_STATUS_SUCCESS;
742  switch_size_t req = *len, wrote = 0, need = *len;
743  int to_count = 0;
744 
745  while ((wrote < req && status == SWITCH_STATUS_SUCCESS) || (need == 0 && status == SWITCH_STATUS_BREAK) || status == 730035 || status == 35) {
746  need = req - wrote;
747  status = apr_socket_send(sock, buf + wrote, &need);
748  if (status == SWITCH_STATUS_BREAK || status == 730035 || status == 35) {
749  if (++to_count > 60000) {
750  status = SWITCH_STATUS_FALSE;
751  break;
752  }
753  switch_yield(10000);
754  } else {
755  to_count = 0;
756  }
757  wrote += need;
758  }
759 
760  *len = wrote;
761  return (switch_status_t)status;
762 }
switch_byte_t switch_byte_t * buf
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
Definition: switch_utils.h:908
uintptr_t switch_size_t
switch_status_t
Common return values.
switch_status_t switch_socket_send_nonblock ( switch_socket_t sock,
const char *  buf,
switch_size_t len 
)

Definition at line 764 of file switch_apr.c.

References SWITCH_STATUS_GENERR.

765 {
766  if (!sock || !buf || !len) {
767  return SWITCH_STATUS_GENERR;
768  }
769 
770  return apr_socket_send(sock, buf, len);
771 }
switch_byte_t switch_byte_t * buf
switch_status_t switch_socket_sendto ( switch_socket_t sock,
switch_sockaddr_t where,
int32_t  flags,
const char *  buf,
switch_size_t len 
)
Parameters
sockThe socket to send from
whereThe apr_sockaddr_t describing where to send the data
flagsThe flags to use
bufThe data to send
lenThe length of the data to send

Definition at line 773 of file switch_apr.c.

References SWITCH_STATUS_GENERR.

Referenced by check_rtcp_and_ice(), do_dtls(), handle_ice(), ice_out(), ping_socket(), rtp_common_read(), rtp_common_write(), switch_ivr_park(), switch_rtp_set_local_address(), switch_rtp_write_frame(), switch_rtp_write_raw(), and switch_stun_lookup().

775 {
776  if (!where || !buf || !len || !*len) {
777  return SWITCH_STATUS_GENERR;
778  }
779  return apr_socket_sendto(sock, where, flags, buf, len);
780 }
switch_byte_t switch_byte_t * buf
switch_status_t switch_socket_shutdown ( switch_socket_t sock,
switch_shutdown_how_e  how 
)

Shutdown either reading, writing, or both sides of a socket.

Parameters
sockThe socket to close
howHow to shutdown the socket. One of:
           SWITCH_SHUTDOWN_READ         no longer allow read requests
           SWITCH_SHUTDOWN_WRITE        no longer allow write requests
           SWITCH_SHUTDOWN_READWRITE    no longer allow read or write requests 
See also
switch_shutdown_how_e
Remarks
This does not actually close the socket descriptor, it just controls which calls are still valid on the socket.

Definition at line 709 of file switch_apr.c.

Referenced by switch_ivr_deactivate_unicast(), switch_rtp_kill_socket(), switch_rtp_udptl_mode(), and switch_stun_lookup().

710 {
711  return apr_socket_shutdown(sock, (apr_shutdown_how_e) how);
712 }
switch_status_t switch_socket_timeout_set ( switch_socket_t sock,
switch_interval_time_t  t 
)

Setup socket timeout for the specified socket

Parameters
sockThe socket to set up.
tValue for the timeout.
  t > 0  – read and write calls return APR_TIMEUP if specified time
            elapsess with no data read or written
  t == 0 – read and write calls never block
  t < 0  – read and write calls block

Definition at line 856 of file switch_apr.c.

857 {
858  return apr_socket_timeout_set(sock, t);
859 }