Skip to main content

Socket Server with ThreadPool

Project description

SockServer

Screenshot

Install

  1. SockServer文件夹添加到你的Python::3第三方库文件夹(**/site-packages/)中,即可完成安装
  2. python3 setup.py install

Usage

from SockServer import SockServer

server = SockServer(8000, workers=8)


@server.register()
def hello(who: str):
    """
    :param who:
    :return: 
    """
    if who == 'me':
        return "who should not be 'me'"
    return {'status': True, 'msg': 'hello ' + who.strip()}


if __name__ == '__main__':
    server.start()

Client Lib for C

  • Install Client LIB
mkdir /usr/local/include/SockClient
mv Client/utils/* /usr/local/include/SockClient/
  • Usage
#include "SockClient/SockClient.h"

int main(int argc, char **argv) {
    struct sockaddr_in*servaddr = default_addr();
    string_t recvbuf = new_string();

    char postbuf[BUFFER_SIZE];
    memset(postbuf, 0, BUFFER_SIZE);
    strcpy(postbuf, argv[1]);
    for (int i=2; i < argc; ++i) {
        strcat(postbuf, " ");
        strcat(postbuf, argv[i]);
    }

    puts(postbuf);
    call_api(servaddr, postbuf, recvbuf);
    stringPuts(recvbuf);

    deleteString(recvbuf);
    free(servaddr);
    return 0;
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SockServer-0.0.4.tar.gz (4.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page