Jump to content

UDP Server Sending Back to Client


Recommended Posts

I made a small project in Delphi to receive a udp message from an AutoIt script on another pc. The Delphi program tells me that the port for the sender is 4704. But later when I run it again, (run both again) it tells me the sender port is 4705.

But how do I know if that is correct or not because UDPOpen might actually be using that port? The function UDPOpen doesn't tell you what port it is using does it? it only tells you what port you want to communicate with on another PC.

To me it looks like the problem is that you cannot specify the local IP or port to be used to send UDP data. UDPOpen could create a socket for sending data and open a specified port on the local pc using a specified IP on the local PC exactly the same as UDPBind does. It should not be tied in any way to what it is going to send or where it is going to send it.

Then UDPSend should use this socket, and specify the data, the target IP and the target port. When the data is received it will be seen to come from the IP and port that was specified when UDPOpen was called.

I might have misunderstood what is happening but I cannot tell from the information in the help what port is used by UDPOpen and UDPSend.

Why cannot UDPBind create a socket that can be used to send and receive data? Or have a flag to specify whether it is to be used to send or receive? I tried using the socket returned by UDPBind, changing the 2nd and 3rd elements to the target IP and port and using that as the socket array passed to UDPSend but it didn't work :D

EDIT: Various alterations so that it might make more sense.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 1 month later...

each time you call UdpOpen(ip,port) you create a local port for sending (a random one) and connect that port to the remote listening port of the target address so getting different ports when you try to see the port that is sending the data is ok

ex:

udpopen(192.168.0.2,8080)

this opens a udp port for sending data on the local machine (in range x-65535) wich connects to the listening port(8080 in this case) on the requested address (192.168.0.2 in this case) so when you want to send data from the client to the server you send it to the initial port(8080) BUT when you send data back from the server to the client you must use the port opened by the client for sending

btw any ideea when this is gonna be in a release? cause i've reached a dead stop in a project of mine because i really need to send data to people behind routers and the problem is... they send me data and normally i could reply on the same socket and get past the whole router problem but since i don't know where to send the data to... i need to create a new socket to the other user and and if they don't have port forwarding set up it won't work ^_^

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...