Copies my address into the passed argument
| 800 | |
| 801 | // Copies my address into the passed argument |
| 802 | void nw_GetMyAddress(network_address *addr) { |
| 803 | socklen_t len; |
| 804 | SOCKADDR_IN in_addr; |
| 805 | |
| 806 | memset(&My_addr, 0, sizeof(network_address)); |
| 807 | if (TCP_active) { |
| 808 | // assign the TCP_* sockets to the socket values used elsewhere |
| 809 | Unreliable_socket = &TCP_socket; |
| 810 | Reliable_socket = &TCP_reliable_socket; |
| 811 | Listen_socket = &TCP_listen_socket; |
| 812 | |
| 813 | // get the socket name for the TCP_socket, and put it into My_addr |
| 814 | len = sizeof(SOCKADDR_IN); |
| 815 | if (getsockname(*Unreliable_socket, (SOCKADDR *)&in_addr, &len) == SOCKET_ERROR) { |
| 816 | mprintf(0, "Unable to get sock name for TCP unreliable socket (%s)\n", WSAGetLastError()); |
| 817 | return; |
| 818 | } |
| 819 | |
| 820 | memcpy(My_addr.address, &in_addr.sin_addr, 4); |
| 821 | |
| 822 | // My_addr.port = in_addr.sin_port; |
| 823 | My_addr.port = ntohs(in_addr.sin_port); |
| 824 | } |
| 825 | |
| 826 | *addr = My_addr; |
| 827 | } |
| 828 | |
| 829 | // Returns internet address format from string address format...ie "204.243.217.14" |
| 830 | // turns into 1414829242 |
no outgoing calls
no test coverage detected