RejectedSoftware Forums

Sign up

udp source port

I have a client that connects through udp at a given port. In the received packets, source port is set and is the port the client assumes the server will respond at. This is normal behaviour according to wikipedia.
In vibed, I see no way to access that source_port field in udp packets, how is it dealt with?

Re: udp source port

On Tue, 25 Nov 2014 11:39:50 GMT, maarten wrote:

I have a client that connects through udp at a given port. In the received packets, source port is set and is the port the client assumes the server will respond at. This is normal behaviour according to wikipedia.
In vibed, I see no way to access that source_port field in udp packets, how is it dealt with?

UDPConnection.recv have optional parameter NetworkAddress peer_address.
UDP echo example, sends packet back to source ip:port:

shared static this()
{
	NetworkAddress addr;
	auto udp_listener = listenUDP(1234);
	while (true) {
		auto pack = udp_listener.recv(null, &addr);
		udp_listener.send(pack, &addr);
	}
}

Re: udp source port

Great, how would connecting work? (mimicking the client to test a few things)

On Tue, 25 Nov 2014 14:10:46 GMT, akaDemik wrote:

On Tue, 25 Nov 2014 11:39:50 GMT, maarten wrote:

I have a client that connects through udp at a given port. In the received packets, source port is set and is the port the client assumes the server will respond at. This is normal behaviour according to wikipedia.
In vibed, I see no way to access that source_port field in udp packets, how is it dealt with?

UDPConnection.recv have optional parameter NetworkAddress peer_address.
UDP echo example, sends packet back to source ip:port:

shared static this()
{
	NetworkAddress addr;
	auto udp_listener = listenUDP(1234);
	while (true) {
		auto pack = udp_listener.recv(null, &addr);
		udp_listener.send(pack, &addr);
	}
}

Re: udp source port

I do not understand the question. UDP is a connectionless protocol. You can store the peer_address to find out who among them "new".

On Tue, 25 Nov 2014 17:11:16 GMT, maarten wrote:

Great, how would connecting work? (mimicking the client to test a few things)

Re: udp source port

How do you send a packet and set the source address of that packet (ie connecting as the client I described)
But I assume source port is correctly set when you initialize UdpConnection with listenudp, completely forgot about that...