Destination host not receive UDP message from source host using TIdUDPServer.Send - delphi

I use TIdUDPServer in this scenario:
Host 192.168.1.10: IdUDPServer1.Active := True using dynamic port (e.g.: 60112)
Host 192.168.1.20: IdUDPServer2.Active := True using dynamic port (e.g.: 50332)
When I invoke IdUDPServer1.Send('192.168.1.20', 50332, 'Hello'), the host
192.168.1.20 didn't receive any UDP message.
I then invoke IdUDPServer2.Send('192.168.1.10', 60112, 'Hello'), the host 192.168.1.10 receive the UDP message. Both hosts are able to receive UDP messages from each other then.
Similarly, if I send message from IdUDPServer2 first, the IdUDPServer1 will not receive any UDP message.
This strange problem always happens to UDP server that first send a message.
This problem doesn't happen if both IdUDPServer1 and IdUDPServer2 started in same host (e.g.: localhost or same pc).
I didn't assign any port number to both TIdUDPServer instance and let the library to assign a dynamic port for me. Hence, Windows 10 didn't prompt any Firewall warning.

Related

Delphi Indy TCP Server Remote Client-IP

When a client connects to my TCP server, i can identify him via:
AContext.Binding.PeerIP
This works for clients in a local network, and also for remote clients.
But on some sites there are 2 routers.
So the TCP-port has to be forwarded in both router.
This means that all clients that are connecting remotely are identified as '192.168.1.1' instead of with their own IP address.
When i am doing the same with a DataSnap server, i can use:
IpAddress := Session.GetData('RemoteIP');
This gives back the 'real' clients IP, event through both routers.
So, is there a way to do the same with an Indy TCP-server?

Socket connection with different ports

I'm trying to run a socket connection from my iOS app to a bespoke server.
The iOS communicates via UDP to the server on port 12345. The request needs to come from socket 54321 on the device.
How do I open up a socket connection on iOS that communicates to a server on one port but listens via a different port.
I have followed the example on:
https://www.raywenderlich.com/3932/networking-tutorial-for-ios-how-to-create-a-socket-based-iphone-app-and-server
But this does not cover the local port
I have also looked at the documentation on https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/UsingSocketsandSocketStreams.html but I am finding it unclear due to my limited knowledge of socket connections.
I am currently attempting to use https://github.com/robbiehanson/CocoaAsyncSocket/wiki/Reference_GCDAsyncSocket
But I don't seem to be able to control the local port.
Thanks in advance
Normally you don't care about the sending socket, but when you create your AsyncUDPSocket you can use bindToPort: to set its port. Then use sendData:toHost:port:timeout:tag: to send the data

Monitor data transmission on TCP/IP adress and/or Port using wireshark

I made a C# program with a client and a server that comunicates fine between them. Information is received by the server and stored in a MySQL Database with no problems. However I wanted to use wireshark to monitor how safe/encrypted was the information and couldn't find the communication using wireshark. My program uses sockets to connect the server and client, on my test the server and client are running at adress 127.0.0.1 or local IP machine (something like 192.168.13.191), server listens/connects using port 3608 and client a much higher random port, and all the filters I used on wireshark return nothing.
So far I tried:
ip.addr == 127.0.0.1 (show only packages whose origin or destination are 127.0.0.1)
ip.addr == 192.168.13.191 (same as above)
tcp.port == 3608 (show only packages whose origin or destination is this port)
tcp.port == client_port (same as above)
tcp contains 01:00:00:3B (only packages with a few of the bytes I'm sending)
My idea was to find at least one message from the client to server and use the "Follow TCP stream" option from wireshark, but all these filters return a black screen when used individually. I have no idea why, because when I run netstat -a on a windows command I can see the program have a established connection and is also listening for new connections on port 3608. Anyone have any idea what is going on or what filter should I use? Operational system somehow is "redirecting" traffic from port 3608 to another?
Thanks!
Wireshark doesn't pick up loopback packets. You'll have to install the client or server on another machine and then try again.
EDIT: After doing some reading I've discovered that this really doesn't have anything to do with Wireshark but with the way WinPcap works. In any case, running the client or server on another machine will solve the problem.

Pulseaudio to output RTP to internet

I want pulseaudio (remote instance) to push audio sent to the primary alsa device straight to RTP over the internet so that I could listen to it on VLC on my home computer.
in my /etc/pulse/default.pa
load-module module-rtp-send source=alsa_output.0.analog-stereo.monitor destination=x.x.x.x port=8080 loop=1
Where x.x.x.x is the internet IP of my server
After starting pulseaudio,netstat shows (I cannot connect from remote VLC to this)
udp 0 0 10.170.94.16:58606 x.x.x.x:9875 ESTABLISHED 2109/pulseaudio
udp 0 0 10.170.94.16:35597 x.x.x.x:8080 ESTABLISHED 2109/pulseaudio
It works with cvlc to produce the intended results (I can connect from remove VLC to this)
cvlc -vvv pulse://alsa_output.0.analog-stereo.monitor --sout '#transcode{acodec=mpga,ab=32,channels:1}:rtp{sdp=rtsp://0.0.0.0:8080/test.sdp}'
which produces
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1944/pulseaudio
And I can connect to it.
So what I think I understand is that pulseaudio is working correctly, and is sending the audio to port 8080. However, it's not listening for incoming connections to route the data to. How would I tell pulseaudio, or set up the routing so that port 8080 transmits the audio provided by rtp when an inbound connection occurs. I also see that cvlc is using rtsp as the source.
Still a bit confused..
RTP uses the stateless UDP protocol as a transport: it does not require the destination end to acknowledge any incoming packets. It cannot tell you if the connection has actually been established, other than if the remote end explicitly rejected it. This feature allows for doing broadcast on a LAN because multiple clients can listen to the packets as they wish, but it makes debugging unicast connections slightly more complicated.
When doing unicast UDP (like you are trying to achieve), once it's out on the Internet, it should get to your destination. Do you have a firewall? Unless your machine is connected directly to your modem, it is very likely that you have at least network address translation which would prevent the packets from reaching your computer. Look for port forwarding in your gateway/router configuration.
You can test if you are actually receiving the packets by using tcpdump. When running it, you will see some noise from other connections, along with packets that look like this:
08:19:38.483895 IP y.y.y.y.zzzz > x.x.x.x:8080: UDP, length 1292
Also, PulseAudio does not use RTSP, so VLC needs to open an RTP stream only. Simply typing rtp://0.0.0.0:8080 should do it.

how could an erlang port's port info change to undefined?

I get a erlang server, and many clients use tcp to connect to the server.
After some minutes, use erlang:ports() and erlang:port_info(), I can find some port's port_info is undefined, and the port is closed.I can't find anyway to remove it from ports.
So why did it happen, and how could I remove these undefined port from erlang ports?
The erlang:port_info/1 function returns undefined if the port is not open.
You're calling that function on a port which you didn't open or that has been closed.
Please note that if the Erlang process which created the port (the connected process) terminates, the port will automatically close.

Resources