Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6749723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:43:27+00:00 2026-05-26T12:43:27+00:00

I have the following setup: The server will connect via Bluetooth to several devices

  • 0

I have the following setup:

The server will connect via Bluetooth to several devices that are sending a discrete signal. Then there will be n clients that can inquiry the server (via web services probably) for which devices are connected and listen to the signal from the devices they want.

I think the best way to implement this is: when the server connects to a device via BT, it will open a Socket to a local port and send the data there. When a client ask for the available devices, the server will return a Dictionary and then the client just have to listen to that port.

But i’m having some problems with the socket implementation. How can I create and write the signal to a local port?

This is what I got so far:

class Device {
    ...
    public EndPoint Connect() {
        // create a bt connection to the device

        _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        var endPoint = new IPEndPoint(IPAddress.Parse(_localIp), 0);
        _socket.Bind(endPoint);

        return endPoint;
    }

    private void OnBtDataReceived(object sender, wclDataEventArgs e) {
        _socket.Send(e.Data);
    }
}

But when reaching the _socket.Send(e.Data); I receive the following exception:

A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied

Is this the right approach but it needs to have someone connected to the socket to read the data?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:43:28+00:00Added an answer on May 26, 2026 at 12:43 pm

    You can use UDP Broadcast as the comments suggest where you don’t have to establish a connection. The server justs sends the data out on one port and any interested client can receive that data on that port.

    If you want to distinguish between your devices you might have to broadcast every devices data on a separate port. That might be a lot of (unnecessary) network traffic whn you have many devices.

    The other option is using TCP.
    Your server as to listen for incoming connections from your clients:

    _socket.Bind(new IPEndPoint(IPAddress.Any, 1234));
    _socket.Listen(10);
    _socket.BeginAccept(onAccept, _socket);
    

    In onAccept you have access to the clientsocket and can send data or store the reference to the socket somewhere to send data later on:

    private static void onAccept(IAsyncResult ar)
    {
        Socket clientSocket = ((Socket) ar.AsyncState).EndAccept(ar);
    
        // begin to accept the next client connection
        _socket.BeginAccept(onAccept, _socket);
    
        // this is the socket you can send data to the connected client:
        clientSocket.Send(data);
    }
    

    The TCP approach has the advantage that your server only sends data when there are connected clients and your server is aware of the number of clients connected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you have the following setup. You have a server with the basepath
I have this following setup, a textarea named with some data in it that
I have the following setup: Sharepoint 2010 with SQL Server and Office 2010. This
I have following setup, but when I put 1024 and replace all 512 with
I have the following setup: Code on my local machine (OS X) shared as
I have a following setup: App - Magnolia site running under Tomcat 6.0.16 ISAPI
I have the following setup, and I need to know how to persist state.
I have the following setup, and the empty view text doesn't show up... protected
I have the following setup: eclipse a standard Java project (A) an eclipse plugin
How do you setup a multi-developer XDebug PHP environment? I have the following setup:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.