Author | Topic: UDP Connection | |
---|---|---|
Manfred Sauer | UDP Connection on Fri, 27 Sep 2019 08:46:28 +0200 Hello, I have a device that is able to send and receive data via udp on a specific port. //this way I get a socket, but if I specify the IP of the device instead of INADDR_ANY the socket will be 0 nSocket := SocketCreate( SOCK_DGRAM , , INADDR_ANY, 5168, @nError) SocketSetOption( nSocket, SO_BROADCAST, .T. ) SocketSetOption( nSocket, SO_REUSEADDR, .T. ) nBytesWritten := SocketSendTo(nSocket,myData, , , {"192.168.99.160"},@nError) either SocketSend or SocketSendTo do not write anything, instead the error is WSAEADDRNOTAVAIL But I can ping the adress and from a C++ program I am able to send data via udp. How to do a propper UDP connection? | |
Manfred Sauer | Re: UDP Connection on Fri, 27 Sep 2019 13:44:52 +0200 Found the mistake, works no es expected: nSocket := SocketNew( ,SOCK_DGRAM , , @nError) lRet := SocketConnect( nSocket , , "192.168.99.160" , 5168 @nError ) SocketSetOption( nSocket, SO_BROADCAST, .T. ) SocketSetOption( nSocket, SO_REUSEADDR, .T. ) SocketSend(nSocket,myData, , , , @nError ) Am 27.09.2019 um 08:46 schrieb Manfred Sauer: > Hello, > I have a device that is able to send and receive data via udp on a > specific port. > > //this way I get a socket, but if I specify the IP of the device instead > of INADDR_ANY the socket will be 0 > > nSocket := SocketCreate( SOCK_DGRAM , , INADDR_ANY, 5168, @nError) > SocketSetOption( nSocket, SO_BROADCAST, .T. ) > SocketSetOption( nSocket, SO_REUSEADDR, .T. ) > > nBytesWritten := SocketSendTo(nSocket,myData, , , > {"192.168.99.160"},@nError) > > either SocketSend or SocketSendTo do not write anything, instead the > error is WSAEADDRNOTAVAIL > But I can ping the adress and from a C++ program I am able to send data > via udp. > > How to do a propper UDP connection? |