Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

SOFIAPUBFUN su_socket_t su_socket ( int  af,
int  socktype,
int  proto 

Create an endpoint for communication.

Create a socket endpoint for communication.

af addressing family
socktype socket type
proto protocol number specific to the addressing family
The newly created socket is nonblocking unless global variable su_socket_blocking is set to true.

Also, the newly created socket is closed on exec() if global variable su_socket_close_on_exec is set to true. Note that a multithreaded program can fork() and exec() before the close-on-exec flag is set.

A valid socket descriptor or INVALID_SOCKET (-1) upon an error.

Definition at line 84 of file su.c.

References su_setblocking(), and su_socket().

Referenced by init_test(), stun_obtain_shared_secret(), stun_test_lifetime(), su_socket(), test_sockaddr(), and tport_base_connect().

  struct ifconf ifc;
  int numifs = 64;
  char *buffer;
  struct ifreq ifr;
  int const su_xtra = 0;

  su_socket_t s = socket(af, socktype, proto);

  if (s != INVALID_SOCKET) {
    if (su_socket_close_on_exec)
      fcntl(s, F_SETFD, FD_CLOEXEC); /* Close on exec */
    if (!su_socket_blocking)  /* All sockets are born blocking */
      su_setblocking(s, 0);

  /* Use AP we have raised up */
  memset(&ifr, 0, sizeof(struct ifreq));
  strncpy(ifr.ifr_name, (char const *) su_global_ap_name, IFNAMSIZ);

  /* Assign socket to an already active access point (interface) */
  ioctl(s, SIOCSIFNAME, &ifr);
  ioctl(s, SIOCIFSTART, &ifr);

  return s;

Generated by  Doxygen 1.6.0   Back to index