Lacita

Socket UDP Send not working

7 posts in this topic

Posted (edited)

I got the problem with this FB. This work:9.PNG

But this doesn't! Its error is 0400, the Input value is out of range(?)7.PNG

This is variable table.

8.PNG

Help me check this. Thank you guys.

 

Edited by Lacita

Share this post


Link to post
Share on other sites

Posted (edited)

How come you use port 60001 and not 6001?

Can you try with 6001, I know the range is up to 65535 but you can give it a try.

Edited by andrei.apopei

Share this post


Link to post
Share on other sites

Port Number does not matter AFAIK, as long as it's not the common port number used in other TCP/UDP protocol (like port 80) or not being used by another Socket.

I see in your variable tables that you are Initializing some values, such as the Socket definition.
I think, prevent to Initialize the "Handle" value of the Socket. When you are Creating a Socket by the Create FB, you will get a new value assign to that Handle, just as a pointer. This is later on Outputted by the Create FB.

Try checking the current value of the Handle in your Socket. It will not be able to send anything if the value is 0.

Share this post


Link to post
Share on other sites
12 hours ago, innoaloe said:

Port Number does not matter AFAIK, as long as it's not the common port number used in other TCP/UDP protocol (like port 80) or not being used by another Socket.

I see in your variable tables that you are Initializing some values, such as the Socket definition.
I think, prevent to Initialize the "Handle" value of the Socket. When you are Creating a Socket by the Create FB, you will get a new value assign to that Handle, just as a pointer. This is later on Outputted by the Create FB.

Try checking the current value of the Handle in your Socket. It will not be able to send anything if the value is 0.

I checked that Handle value, it's different from my initial value (= 0), it's 1 as you can see.

But Send FB still not work. 

What value should that Handle be? Or what shoul I do now?

10.PNG

Share this post


Link to post
Share on other sites

I think I'm starting to get what's happening... but you need to try it.
Delete all of the Initial Values set for your Socket variable. In the SktUDPCreate documentation it describes that both SrcAdr and DstAdr sections will be filled with zero once the socket is created. As UDP is an unconnected communication, you don't need to specify any source IP Address.

If the UDPCreate is successful, fill the DstAdr with your target device IPAddress and PortNumber, then try the UDPSend command.


The Handle value is basically just a pointer. If you Create a socket one time in the entire program, it will be filled with 1. If you create another socket, it will have 2 as the handle value. If say socket 1 is closed properly, next time you open a socket it will get 1 as the handle value. So it's predetermined by the CPU.

Share this post


Link to post
Share on other sites

Posted (edited)

5 hours ago, innoaloe said:

I think I'm starting to get what's happening... but you need to try it.
Delete all of the Initial Values set for your Socket variable. In the SktUDPCreate documentation it describes that both SrcAdr and DstAdr sections will be filled with zero once the socket is created. As UDP is an unconnected communication, you don't need to specify any source IP Address.

If the UDPCreate is successful, fill the DstAdr with your target device IPAddress and PortNumber, then try the UDPSend command.


The Handle value is basically just a pointer. If you Create a socket one time in the entire program, it will be filled with 1. If you create another socket, it will have 2 as the handle value. If say socket 1 is closed properly, next time you open a socket it will get 1 as the handle value. So it's predetermined by the CPU.

Oh wow thank you very much innoaloe, it works!!!

This is my setup, hope it will help for anyone have to face this problem.

 

 

13.PNG

Edited by Lacita

Share this post


Link to post
Share on other sites

Good to know that it solved the issue :)

Share this post


Link to post
Share on other sites

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