Click here to Skip to main content
14,603,017 members
   

C#

 
AnswerRe: How to get the actual, GENERATED source code from my site? Pin
Mycroft Holmes3-Jul-20 12:30
professionalMycroft Holmes3-Jul-20 12:30 
AnswerRe: How to get the actual, GENERATED source code from my site? Pin
F-ES Sitecore5-Jul-20 5:31
mveF-ES Sitecore5-Jul-20 5:31 
QuestionTask.Run.Wait Pin
Bernhard Hiller3-Jul-20 0:16
MemberBernhard Hiller3-Jul-20 0:16 
AnswerRe: Task.Run.Wait Pin
OriginalGriff3-Jul-20 0:49
mveOriginalGriff3-Jul-20 0:49 
GeneralRe: Task.Run.Wait Pin
Bernhard Hiller3-Jul-20 2:18
MemberBernhard Hiller3-Jul-20 2:18 
GeneralRe: Task.Run.Wait Pin
OriginalGriff3-Jul-20 4:00
mveOriginalGriff3-Jul-20 4:00 
AnswerRe: Task.Run.Wait Pin
jsc423-Jul-20 6:31
professionaljsc423-Jul-20 6:31 
QuestionStrange characters in JSON RPC server response Pin
pkfox1-Jul-20 3:37
professionalpkfox1-Jul-20 3:37 
Hi all, just revisiting some code that scans a local LAN for servers broadcasting on UDP port 3483 and I'm seeing strange characters in the response string when I run the code on Win 10

I expect
"ENAME0\LMSPi\JSON0\9000"

but I'm getting
"ENAME\u0005LMSPi0JSON\u00049000"

I'm sure the weren't there when I ran the code under Win 7
What I'm after is the port number the server is running on which is the 9000 after JSON ( without the u0004 )
Any idea why I'm seeing these characters ?
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;

namespace LMS
{
    class ScanLAN
    {
        [STAThread]
        static int Main()
        {
            ScanForServer();

            return 0;
        }

        static void ScanForServer()
        {
            IPEndPoint ReceiveIP = null;
            UdpClient listener = null;
            Byte[] RequestData = null;
            byte[] BytesReceived = null;

            string RetVal = "No response from LAN";
            int UDPPort = 3483;

            try
            {
                Console.WriteLine($"Starting LAN broadcast on port {UDPPort}...");
                ReceiveIP = new IPEndPoint(IPAddress.Any, UDPPort);
                listener = new UdpClient(UDPPort);

                // RequestData will contain a server request in the expected format
                // ReceiveIP will contain the ip address of a discovered server.

                RequestData = listener.Receive(ref ReceiveIP);

                if (RequestData != null && RequestData.Length > 0)
                    RetVal = Encoding.UTF8.GetString(RequestData);

                Console.WriteLine($"Initial response data {RetVal}");

                // Which I then send back as a request
                listener.Send(RequestData, RequestData.Length, ReceiveIP);

                // This will return server information such as the tcp port, name,uuid and software version.

                BytesReceived = listener.Receive(ref ReceiveIP);

                if (BytesReceived != null && BytesReceived.Length > 0)
                    RetVal = Encoding.UTF8.GetString(BytesReceived);

                    Console.WriteLine($"Final response data {RetVal}");

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (listener != null && listener.Client.Connected)
                    listener.Close();
            }
        }
    }
}


"We can't stop here - this is bat country" - Hunter S Thompson - RIP

AnswerRe: Strange characters in JSON RPC server response Pin
Luc Pattyn1-Jul-20 5:33
sitebuilderLuc Pattyn1-Jul-20 5:33 
GeneralRe: Strange characters in JSON RPC server response Pin
pkfox1-Jul-20 6:23
professionalpkfox1-Jul-20 6:23 
GeneralRe: Strange characters in JSON RPC server response Pin
pkfox1-Jul-20 6:46
professionalpkfox1-Jul-20 6:46 
GeneralRe: Strange characters in JSON RPC server response Pin
Luc Pattyn1-Jul-20 9:36
sitebuilderLuc Pattyn1-Jul-20 9:36 
GeneralRe: Strange characters in JSON RPC server response Pin
pkfox1-Jul-20 10:40
professionalpkfox1-Jul-20 10:40 
GeneralRe: Strange characters in JSON RPC server response Pin
Luc Pattyn5-Jul-20 3:27
sitebuilderLuc Pattyn5-Jul-20 3:27 
GeneralRe: Strange characters in JSON RPC server response Pin
pkfox5-Jul-20 5:45
professionalpkfox5-Jul-20 5:45 
GeneralRe: Strange characters in JSON RPC server response Pin
Luc Pattyn5-Jul-20 6:19
sitebuilderLuc Pattyn5-Jul-20 6:19 
GeneralRe: Strange characters in JSON RPC server response Pin
pkfox5-Jul-20 22:15
professionalpkfox5-Jul-20 22:15 
GeneralRe: Strange characters in JSON RPC server response Pin
Luc Pattyn6-Jul-20 2:12
sitebuilderLuc Pattyn6-Jul-20 2:12 
GeneralRe: Strange characters in JSON RPC server response Pin
pkfox6-Jul-20 3:08
professionalpkfox6-Jul-20 3:08 
GeneralRe: Strange characters in JSON RPC server response Pin
Luc Pattyn6-Jul-20 3:23
sitebuilderLuc Pattyn6-Jul-20 3:23 
GeneralRe: Strange characters in JSON RPC server response Pin
Luc Pattyn6-Jul-20 6:14
sitebuilderLuc Pattyn6-Jul-20 6:14 
GeneralRe: Strange characters in JSON RPC server response Pin
pkfox6-Jul-20 6:56
professionalpkfox6-Jul-20 6:56 
GeneralRe: Strange characters in JSON RPC server response Pin
Luc Pattyn6-Jul-20 7:16
sitebuilderLuc Pattyn6-Jul-20 7:16 
GeneralRe: Strange characters in JSON RPC server response Pin
pkfox6-Jul-20 7:27
professionalpkfox6-Jul-20 7:27 
GeneralRe: Strange characters in JSON RPC server response Pin
Luc Pattyn6-Jul-20 7:43
sitebuilderLuc Pattyn6-Jul-20 7:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.