Xamarin Forms App as TCP Server

UmairEmUmairEm GBMember ✭✭

Hello,

I have a cross-platform forms app (iOS and Android) which provides a specific service. This service code is in PCL part of the project and I want to use it on web client as well using my app as server. Is there a way to implement TCP server in the app which listens to incoming connections and provides with the service.

Do I have to use platform specific background services to run TCPListener? The server should only be running when the app is in foreground.

I have tried to look for answers over forums and got bits and pieces.
All I need right now is right direction to go to:

(Can't post links as I am new here)

StackOverflow: [Server Client Application with .NET and Xamarin]
StackOverflow: [Xamarin.Forms Background Thread]
Xamarin Components: [Sockets PCL Plugin]

Any kind of help is highly appreciated.

Cheers.

Posts

  • amirvenusamirvenus USMember ✭✭✭
    Yes you can but it’s not a very good solution.

    It’s because firstly mobile devices lack enough power to act as a server secondly on mobile eco-system the connection might be lost or constantly changed hence causing your app to stop listening on the designated IP address.

    I did something similar before but mind you it was intended for UWP/macOS/WPF only even though I was using Xamarin.Forms.

    The best alternative is to use an RTC technology like WebSync to handle the communications.
Sign In or Register to comment.