Author Topic: UDP and TCP server  (Read 2512 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
UDP and TCP server
« on: March 16, 2022, 03:52:46 PM »
HI Mark,
  Hope you are keeping well  :)

In my project I have to include a UDP and TCP server . I use the TCP client often, but never as a server. Is there any examples for both UDP and TCP server ?

Best Regards

Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: UDP and TCP server
« Reply #1 on: March 16, 2022, 04:12:38 PM »
Hi Neil

Use the HTTP server as reference for a TCP server using simple socket mode.
Use the TELNET server as reference for a TCP server using buffer socket mode.

The only difference between a UDP client and a UDP server is that the USB server is set to listening mode rather than actively connecting to a remote UDP server. The UDP callbacks are otherwise identical. As a server you will generally be listening for data which can arrive at any time and when it does you will receive an appropriate callback event to handle the data - the server will generally make a not of the client's details (eg. its IP address and source port) and can subsequently send data to it in the same way as a client does.

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: UDP and TCP server
« Reply #2 on: March 16, 2022, 04:16:15 PM »
Hi Mark,
  Many thanks for the reply. Is there any documentation on this?

Best Regards
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: UDP and TCP server
« Reply #3 on: March 16, 2022, 05:50:46 PM »
Neil

For Telnet there is:
https://www.utasker.com/docs/uTasker/uTaskerTELNET.PDF
(although not a complete description)

For TCP there is:

https://www.utasker.com/forum/index.php?topic=25.0

(which also has examples from Telnet configuration and use)

UDP is so simple it is best to experiment with a simple listener.

Regards

Mark