UDP Socket

Hi ,
Am new to XOJO…
Could u please help me out for below issue?

I have created the project using the UDP socket. , my scope of the project is server need to receive the message from one port and send reply message to the same port. (i have used the Same IP address )

my code is

Dim d As DataGram
Dim reply As string

d = UDPSocket1.Read

AddMessage("Received message: " + d.Data)

reply = "You said " + d.Data
AddMessage("Sending to " + d.address + ": " + reply)

application only received the message from the port, but not allow to send reply message to same port.

Help me out from this…

[quote=186509:@Manikandan Karuppaiah]Hi ,
Am new to XOJO…
Could u please help me out for below issue?

I have created the project using the UDP socket. , my scope of the project is server need to receive the message from one port and send reply message to the same port. (i have used the Same IP address )

my code is

Dim d As DataGram
Dim reply As string

d = UDPSocket1.Read

AddMessage("Received message: " + d.Data)

reply = "You said " + d.Data
AddMessage("Sending to " + d.address + ": " + reply)

application only received the message from the port, but not allow to send reply message to same port.

Help me out from this…[/quote]

You should have a look at the UDPExample.xojo_binary_project in the Example projects/Communication/Internet folder.

Thanks for response;

Based on the UDP examples only i have developed the above mentioned code… In this application allows only received the message from the port, but not allow to send reply message to same port.

[quote=186541:@Manikandan Karuppaiah]Thanks for response;

Based on the UDP examples only i have developed the above mentioned code… In this application allows only received the message from the port, but not allow to send reply message to same port.[/quote]

What port are you trying to use… By default from client to server you never use same port… Client always connect above port 1024 to a listener port… Also if you go below port 1024 you will need root / administrator privilege… See http://en.wikipedia.org/wiki/Port_(computer_networking)

Maybe this link can help you: http://ljensen.com/rb/sockets_readme_framed.htm

This is not true of UDP in general. However, if both apps are running on the same machine, then only one can listen to the port at a time. If the apps are on different machines, then using the same port should work just fine. We need more information about your setup and the error(s) you are getting.

What I don’t get is that apparently the OP has modified the example project from Xojo, which works perfectly here. What did he change that broke it ?

I am very curious to know where do you use same source and destination port to talk to each other… Most of the time I have only seen the client source port higher than 1023 (randomly picked) connect to a listener port

With UDP, there is no source port, only a destination. So it is perfectly acceptable, necessary even, for all the clients to listen on the same port. TCP has the concept of source and destination, but not UDP.

I see what you mean… according to rfc 768 https://tools.ietf.org/html/rfc768 source port is optional in the User Datagram header