UDP Communications help needed
John Sandgrounder (1650) 574 posts |
I have some clients which communicate with my RISCOS Pi server using TCP and everything is fine until a connection drops for whatever reason. The problem then being that the clients take too long to reconnect (and I cannot change the firmware). To avoid this problem, I am trying to use UDP rather than TCP – but not with much success. With TCP the basic algorithm (copied from Stuard Brodie’s !HTTPServr) is that the Server performs the following SWIs:- To setup the server:- SYS “Socket_GetSize” and then in a polling loop (to deal with each connection) :- SYS “Socket_Select” and finally (to close things down) SYS “Socket_Shutdown” I see from the Stronghelp documentation that for UDP I do not need (and can not use) Socket_Listen, but beyond that I am struggling. Does anyone know of any source code examples (in Basic) which will help me (or any other documentation). Or are the differences simple enough to be explained here? |
Colin (478) 2433 posts |
Not seen a BASIC example but https://www.abc.se/~m6695/udp.html is about as simple as it gets if you can translate the C. If you have Acorn C it may well compile. It doesn’t go into the complications of using UDP – I suggest you read up on the relative merits of UDP and TCP for that. |
Rick Murray (539) 13840 posts |
Isn’t the basic difference that TCP attempts to ensure the transmission gets through, while UDP makes no such guarantees? |
Leo Smiers (245) 56 posts |
Yes, UDP is send and forget, while TCP will deliver the message or will give you an error (eg closes the socket. You might notice this however at the next socket write attempt) |