Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

Shmuel Zang

@Shmuel Zang
About
Posts
7
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Is there a basic HTML scripts bundle for VS code and none serve application?
    S Shmuel Zang

    What about bundling your external JavaScript files into one file, using a bundling tool (like webpack) and, write one script tag for the bundled file?

    Web Development asp-net csharp javascript php ruby

  • How to send the 'Connection' header using HttpListenerResponse
    S Shmuel Zang

    Hello all.

    While trying to implement a web-socket handshake, I encountered a weird behavior. It looks like the HttpListenerResponse class doesn't send the 'Connection' header.

    Here is an example for explaining what I mean:

    public void TestWebSocketHttpHandshake()
    {
    int port = 9444;
    ManualResetEvent serverStartedEvent = new ManualResetEvent(false);
    ManualResetEvent clientClosedEvent = new ManualResetEvent(false);

    // HTTP server that gets a web-socket handshake request and,
    // send back a web-socket handshake response.
    async Task RunHttpServer()
    {
        HttpListener hl = new HttpListener();
        hl.Prefixes.Add($"http://+:{port}/");
        hl.Start();
        serverStartedEvent.Set();
        HttpListenerContext hlc = await hl.GetContextAsync();
    
        string secWebSocketKeyHeader = hlc.Request.Headers\["Sec-WebSocket-Key"\]?.Trim();
        string secWebSocketAcceptHeader = Convert.ToBase64String(
            System.Security.Cryptography.SHA1.Create().ComputeHash(
                Encoding.UTF8.GetBytes(secWebSocketKeyHeader + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11")
            )
        );
    
        hlc.Response.StatusCode = (int)HttpStatusCode.SwitchingProtocols; // 101
        hlc.Response.StatusDescription = "Switching Protocols";
        hlc.Response.ProtocolVersion = new Version("1.1");
        hlc.Response.AddHeader("Upgrade", "websocket");
        **hlc.Response.AddHeader("Connection", "Upgrade");**
        hlc.Response.AddHeader("Sec-WebSocket-Accept", secWebSocketAcceptHeader);
    
        hlc.Response.Close();
    
        // Wait for the client to close.
        clientClosedEvent.WaitOne();
        hl.Stop();
    }
    
    // Tcp Client that sends a web-socket handshake request and,
    // writes the received web-socket handshake response.
    async Task RunTcpClient()
    {
        const string eol = "\\r\\n"; // HTTP/1.1 defines the sequence CR LF as the end-of-line marker
    
        // Wait for the server to start.
        serverStartedEvent.WaitOne();
    
        using (TcpClient tc = new TcpClient())
        {
            tc.Connect("localhost", port);
    
            using (NetworkStream ns = tc.GetStream())
            {
                string wsRequest =
                    $"GET /chat HTTP/1.1{eol}Host: localhost:{port}{eol}"+ 
                    $"Upgrad
    
    Web Development tutorial sysadmin security json question

  • Javascript , a devil spawn language.
    S Shmuel Zang

    I can understand your frustration. Maybe you want to take a look on TypeScript.

    JavaScript javascript

  • Why positioning is not working?
    S Shmuel Zang

    Maybe your elements' position is relative. Try to change it to absolute. Something like:

    <img src="images/logo.jpg" style=" margin-top: 0; margin-left: 0px; position: absolute;">
    <img src="images/my_account.png" style="margin-top: 0; margin-left: 500px; position: absolute;">

    Web Development php com question announcement

  • functions
    S Shmuel Zang

    These links can give you an overview about JavaScript functions basics:

    • http://www.w3schools.com/js/js_functions.asp
    • http://www.w3schools.com/js/js_function_definition.asp
    • http://www.w3schools.com/js/js_function_parameters.asp
    • http://www.w3schools.com/js/js_function_invocation.asp
    JavaScript help question

  • Object cloning
    S Shmuel Zang

    Maybe a std::shared_ptr can be helpful for you.

    You can use it as follows:

    #include <memory>

    using namespace std;

    class Person
    {
    shared_ptr<Person> parent;

    public:
    Person(shared_ptr<Person> p) {parent = p;}

    };

    void DoSomething(shared_ptr<Person> p)
    {
    // Do something here
    }

    int main()
    {
    shared_ptr<Person> grandfather = make_shared<Person>(nullptr);
    shared_ptr<Person> father = make_shared<Person>(grandfather);
    shared_ptr<Person> son = make_shared<Person>(father);

    DoSomething(father);
    
    return 0;
    

    }

    C / C++ / MFC question

  • How to add Scrollviewer inside Dragdockpanel?
    S Shmuel Zang

    If you want to scroll the elements of your panel, you can wrap it with a ScrollViewer.

    If yow want to wrap an inner part of the control with a ScrollViewer, you can do it by changing the ControlTemplate of the control.

    WPF help tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups