Hello,
I am having problems using the udpRead/Write function. If I open a socket using the standard Posix functions (outside WinCCOA) I cannot use udpWrite or udpRead to connect to this socket. Also if I open a socket using the udpOpen, I cannot connect from outside WinCCOA using a standard Posix function call to the socket.
What is wrong ? Are the sockets generated by WinCCOA different that the standard Posix socket(AF_INET, SOCK_DGRAM, 0) and the other standard library sys/socket.h ?
In particular the socket id generated by WinCCOA udpOpen (...) , is different than the one generate buy socket(...) . Why is that ? Is there a way to look at the implementation of these WinCCOA function or actually to use the standard Posix functions ?
Thank You
Walter
udp functions (Linux)
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: udp functions (Linux)
I just tested this here on openSuse with 3.15 and it works - although what is a bit strange is that even for a client you need to pass a hostname and port for udpOpen(), but they can be an empty string and 0.
Here is my code which works:
Server
Client
Here is my code which works:
Server
Code: Select all
main()
{
int fd;
DebugN(fd = udpOpen("localhost", 12345));
string host;
unsigned port;
string s;
DebugN(udpRead(fd, s, host, port, 100));
DebugN("data received", s);
udpClose(fd);
}
Code: Select all
main()
{
int fd = udpOpen("", 0);
DebugN(udpWrite(fd, "hello", "localhost", 12345));
udpClose(fd);
}
- walterd
- Posts:38
- Joined: Wed Mar 13, 2013 10:39 pm
Re: udp functions (Linux)
This is not the issue, in fact this is working fine also for me on 3.15 on RH.
The issue is the following. When I create a udp socket server using standard c libraries outside WinCCOA , a client created write or read (udpRead or udpWrite) in WinCCOA is not capable to connect to the server. The same applies also if I create a server using udpOpen in WinCCOA. Any attempt to use a client created using standard c functions (socket ) outside WinCCOA is not working.
This why I have asked if the implementation of udpOpen, udpRead and Write is based on the standard sys/socket.h (the standard Posix framework) or there is something else that is not standard or missing.
What I need is to have a udpServer running on the server hosting WinCCOA that can be reached from clients from WinCCOA and from client software not in WinCCOA.
Thank You for you reply.
Walter
The issue is the following. When I create a udp socket server using standard c libraries outside WinCCOA , a client created write or read (udpRead or udpWrite) in WinCCOA is not capable to connect to the server. The same applies also if I create a server using udpOpen in WinCCOA. Any attempt to use a client created using standard c functions (socket ) outside WinCCOA is not working.
This why I have asked if the implementation of udpOpen, udpRead and Write is based on the standard sys/socket.h (the standard Posix framework) or there is something else that is not standard or missing.
What I need is to have a udpServer running on the server hosting WinCCOA that can be reached from clients from WinCCOA and from client software not in WinCCOA.
Thank You for you reply.
Walter
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: udp functions (Linux)
We use the standard socket() system calls (I don't think there is any other way to do so, since all boils down to kernel system calls).
Is the client you are using running on a different host than the CTRL manager ?
If so, does your client still not work when you run both on the same server ?
I'm thinking of the problem that the server bound the socket only to localhost so it's not reachable from any other host.
Just check what you are using as the "host" argument in udpOpen(). It should not be localhost if you want to be reachable from another host.
And if you did that already, then try to deactivate your firewall.
I can tell you that also an externally developed C-language udp client works with our script based udp server (just tried it with the script above and running the client also locally on the same machine)
Is the client you are using running on a different host than the CTRL manager ?
If so, does your client still not work when you run both on the same server ?
I'm thinking of the problem that the server bound the socket only to localhost so it's not reachable from any other host.
Just check what you are using as the "host" argument in udpOpen(). It should not be localhost if you want to be reachable from another host.
And if you did that already, then try to deactivate your firewall.
I can tell you that also an externally developed C-language udp client works with our script based udp server (just tried it with the script above and running the client also locally on the same machine)
- walterd
- Posts:38
- Joined: Wed Mar 13, 2013 10:39 pm
Re: udp functions (Linux)
No firewall and it is locahost to keep it simple. I'll re-test my development. Thanks