[Pidgin] #17156: getsockname: Windows socket error #10014

Pidgin trac at pidgin.im
Sun Feb 11 06:48:38 EST 2018


#17156: getsockname: Windows socket error #10014
----------------------+------------------------------
 Reporter:  roti_343  |       Owner:  datallah
     Type:  defect    |      Status:  new
Milestone:            |   Component:  winpidgin (gtk)
  Version:  2.11.0    |  Resolution:
 Keywords:            |
----------------------+------------------------------

Comment (by stefanb):

 An alternative solution is probably by using `struct sockaddr_storage`
 which by definition needs to be aligned correctly:

 {{{
 unsigned short
 purple_network_get_port_from_fd(int fd)
 {
         struct sockaddr_storage addr;
         socklen_t len;

         g_return_val_if_fail(fd >= 0, 0);

         len = sizeof(addr);
         if (getsockname(fd, (struct sockaddr *) &addr, &len) == -1) {
                 purple_debug_warning("network", "getsockname: %s\n",
 g_strerror(errno));
                 return 0;
         }

         return ntohs(((struct sockaddr_in) addr).sin_port);
 }
 }}}

 or copy `PurpleSockAddr` approach from `libpurple/util.c`

--
Ticket URL: <https://developer.pidgin.im/ticket/17156#comment:3>
Pidgin <https://pidgin.im>
Pidgin


More information about the Tracker mailing list