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 7847627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:57:58+00:00 2026-06-02T17:57:58+00:00

I have the following code (snips provided below) in my base class for handling

  • 0

I have the following code (snips provided below) in my base class for handling a UDP socket. I am adding support for WinRT (controlled by the #define for WINRT). I have everything working for .Net, but something is going wrong with my WinRT implementation. When I send the data, it is not being received on the server side. Any idea what is going wrong? I don’t see any errors on the client side, just nothing shows up on the server. I have successfully gotten my TCP socket class working, using the DataWriter in a similar way.

        public UdpSocketClient(IPEndPoint remoteEndPoint, int localPort)
        {
            this.remoteEndPoint = remoteEndPoint;
#if WINRT
            this.socket = new DatagramSocket();
            this.socket.MessageReceived += ReceiveCallback;

            // Bind to any port
            Logger.Debug("{0}: UdpSocketClient created. Binding to port {1}.", this, (localPort == 0) ? "[any]" : localPort.ToString());
            IAsyncAction bindAction = this.socket.BindEndpointAsync(new HostName("localhost"), localPort == 0 ? "0" : localPort.ToString());
            bindAction.AsTask().Wait();
            Logger.Trace("{0}: Bind Complete to port {1}", this, this.socket.Information.LocalServiceName);

            // Get IOutputStream
            Logger.Trace("{0}: Getting output stream to {1}.", this, remoteEndPoint);
            IAsyncOperation<IOutputStream> asyncOutput = this.socket.GetOutputStreamAsync(remoteEndPoint.address, remoteEndPoint.port.ToString());
            asyncOutput.AsTask().Wait();
            Logger.Trace("{0}: Got output stream.", this);

            // Create DataWriter
            dataWriter = new DataWriter(asyncOutput.GetResults());
#else
            ...
#endif
        }


        public void SendBuffer(ByteBuffer buffer, int wait = 0)
        {
#if WINRT
            Logger.Trace("{0}: Sending buffer. Wait = {1}", this, wait);
            for (int i = 0; i < buffer.WriteSize(); i++)
                dataWriter.WriteByte(buffer.Buffer()[i]);
            DataWriterStoreOperation op = dataWriter.StoreAsync();
            if (wait != 0) op.AsTask().Wait(wait);
            else op.AsTask().Wait();
            Logger.Trace("{0}: Sending complete.", this);
#else
        ...
#endif
        }

Some relevant logs:

04/23 19:08:57.504 DEBUG: Area Sync: UdpSocketClient created. Binding to port [any].
04/23 19:08:57.505 TRACE: Area Sync: Bind Complete to port 59518
04/23 19:08:57.506 TRACE: Area Sync: Getting output stream to 71.227.179.128:1302.
04/23 19:08:57.507 TRACE: Area Sync: Got output stream.

04/23 19:08:57.604 TRACE: Area Sync: Sending contact packet.
04/23 19:08:57.604 TRACE: Area Sync: Sending buffer. Wait = 0
04/23 19:08:57.605 TRACE: Area Sync: Sending complete.
  • 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-06-02T17:58:00+00:00Added an answer on June 2, 2026 at 5:58 pm

    I figured it out. Apparently it doesn’t like my bind code. The documentation says that you should be able to pass null into the bind, but I always got an exception for that. So, it works if I use the ConnectAsync API:

            public UdpSocketClient(IPEndPoint remoteEndPoint, int localPort)
            {
                this.remoteEndPoint = remoteEndPoint;
    #if WINRT
                this.socket = new DatagramSocket();
                this.socket.MessageReceived += ReceiveCallback;
    
                Logger.Trace("{0}: Connecting to {1}.", this, remoteEndPoint);
                IAsyncAction connectAction = this.socket.ConnectAsync(remoteEndPoint.address, remoteEndPoint.port.ToString());
                connectAction.AsTask().Wait();
                Logger.Trace("{0}: Connect Complete. Status {1}, ErrorCode {2}", this, connectAction.Status, 
                    connectAction.ErrorCode != null ? connectAction.ErrorCode.Message : "None");
    
                dataWriter = new DataWriter(this.socket.OutputStream);
    #else
                ...
    #endif
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code in the html file: <div class=navbar navbar-fixed-top> <div class=navbar-inner> <div
Can I do this? I have the following in my code: public class ARClass
I have the following code which generates XML: $dom = new DomDocument('1.0'); ...snip adding
I have following code.. $query = SELECT quote, author FROM quotes ORDER BY id
I have following code: <?php $select_options = array(); foreach($delivery_options as $option) { $select_options[$option->getDeviceId()] =
I have following code and it returns false for @B LIKE @A comparison in
I have following code $("#in").datepicker({ minDate: 0, onSelect: function (dateText, inst) { dateText =
I have following code if (rs != null) { out.println(result set has got something);
I have following code: <style> .header { height:20px; width:100px; } .content { height:100px; width:100px;
I have following code for opening all files: int ret= open(zFile, flags, mode); posix_fadvise

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.