diff options
Diffstat (limited to 'drivers/unix/packet_peer_udp_posix.cpp')
-rw-r--r-- | drivers/unix/packet_peer_udp_posix.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/unix/packet_peer_udp_posix.cpp b/drivers/unix/packet_peer_udp_posix.cpp index ed295f0459..52f2c07134 100644 --- a/drivers/unix/packet_peer_udp_posix.cpp +++ b/drivers/unix/packet_peer_udp_posix.cpp @@ -96,7 +96,7 @@ Error PacketPeerUDPPosix::put_packet(const uint8_t *p_buffer,int p_buffer_size){ ERR_FAIL_COND_V(peer_addr.type == IP_Address::TYPE_NONE, ERR_UNCONFIGURED); - int sock = _get_socket(peer_addr.type); + int sock = _get_socket(); ERR_FAIL_COND_V( sock == -1, FAILED ); struct sockaddr_storage addr; size_t addr_size = _set_sockaddr(&addr, peer_addr, peer_port); @@ -119,15 +119,15 @@ int PacketPeerUDPPosix::get_max_packet_size() const{ return 512; // uhm maybe not } -Error PacketPeerUDPPosix::listen(int p_port, IP_Address::AddrType p_type, int p_recv_buffer_size) { +Error PacketPeerUDPPosix::listen(int p_port, int p_recv_buffer_size) { close(); - int sock = _get_socket(p_type); + int sock = _get_socket(); if (sock == -1 ) return ERR_CANT_CREATE; - if(p_type == IP_Address::TYPE_IPV6) { + if(ip_type == IP_Address::TYPE_IPV6) { // Use IPv6 only socket int yes = 1; if(setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&yes, sizeof(yes)) != 0) { @@ -136,7 +136,7 @@ Error PacketPeerUDPPosix::listen(int p_port, IP_Address::AddrType p_type, int p_ } sockaddr_storage addr = {0}; - size_t addr_size = _set_listen_sockaddr(&addr, p_port, p_type, NULL); + size_t addr_size = _set_listen_sockaddr(&addr, p_port, ip_type, NULL); if (bind(sock, (struct sockaddr*)&addr, addr_size) == -1 ) { close(); @@ -225,12 +225,12 @@ int PacketPeerUDPPosix::get_packet_port() const{ return packet_port; } -int PacketPeerUDPPosix::_get_socket(IP_Address::AddrType p_type) { +int PacketPeerUDPPosix::_get_socket() { if (sockfd != -1) return sockfd; - sockfd = _socket_create(p_type, SOCK_DGRAM, IPPROTO_UDP); + sockfd = _socket_create(ip_type, SOCK_DGRAM, IPPROTO_UDP); return sockfd; } @@ -259,6 +259,7 @@ PacketPeerUDPPosix::PacketPeerUDPPosix() { packet_port=0; queue_count=0; peer_port=0; + ip_type = IP_Address::TYPE_ANY; } PacketPeerUDPPosix::~PacketPeerUDPPosix() { |