Instance Methodmigueldeicaza.swiftgodot 0.45.0SwiftGodot
getPacketPort
Returns the port of the remote peer that sent the last packet(that was received with getPacket
or getVar(allowObjects:)
).
final func getPacketPort() -> Int32
Other members in extension
Type members
Instance members
func bind(port: Int32, bindAddress: String, recvBufSize: Int32
) -> GodotError Binds this
PacketPeerUDP
to the specifiedport
andbindAddress
with a buffer sizerecvBufSize
, allowing it to receive incoming packets.func close(
) Closes the
PacketPeerUDP
’s underlying UDP socket.func connectToHost(String, port: Int32
) -> GodotError Calling this method connects this UDP peer to the given
host
/port
pair. UDP is in reality connectionless, so this option only means that incoming packets from different addresses are automatically discarded, and that outgoing packets are always sent to the connected address (future calls tosetDestAddress(host:port:)
are not allowed). This method does not send any data to the remote peer, to do that, useputVar(_:fullObjects:)
orputPacket(buffer:)
as usual. See alsoUDPServer
.func getLocalPort(
) -> Int32 Returns the local port to which this peer is bound.
func getPacketIp(
) -> String Returns the IP of the remote peer that sent the last packet(that was received with
getPacket
orgetVar(allowObjects:)
).func isBound(
) -> Bool Returns whether this
PacketPeerUDP
is bound to an address and can receive packets.func isSocketConnected(
) -> Bool Returns
true
if the UDP socket is open and has been connected to a remote address. SeeconnectToHost(_:port:)
.func joinMulticastGroup(multicastAddress: String, interfaceName: String
) -> GodotError Joins the multicast group specified by
multicastAddress
using the interface identified byinterfaceName
.func leaveMulticastGroup(multicastAddress: String, interfaceName: String
) -> GodotError Removes the interface identified by
interfaceName
from the multicast group specified bymulticastAddress
.func setBroadcastEnabled(Bool
) Enable or disable sending of broadcast packets (e.g.
set_dest_address("255.255.255.255", 4343)
. This option is disabled by default.func setDestAddress(host: String, port: Int32
) -> GodotError Sets the destination address and port for sending packets and variables. A hostname will be resolved using DNS if needed.
func wait(
) -> GodotError Waits for a packet to arrive on the bound address. See
bind(port:bindAddress:recvBufSize:)
.