Search code examples
ddosg-wan

How to make a G-WAN servlet close its connection silently without sending any reply


How to have gwan send no reply to some requests, i.e. make a servlet closed silently without building and sending a reply?

It is useful to reduce the out-going bandwidth from the server side.

For collecting data only, there's no need to respond anything to the client.


Solution

  • You can also close the connection from the servlet by doing something like (untested):

    #include <sys/socket.h>
    
    char buf[1024];
    int s = (int)get_env(argv, CLIENT_SOCKET);
    shutdown(s, SHUT_WR);
    while(read(s, buf, sizeof(buf)) > 0);
    close(s);
    return 500;
    

    Then return something like 500 like above so you don't have to build a reply.