Skip to content

Instantly share code, notes, and snippets.

View ssrlive's full-sized avatar

ssrlive

  • telegram: realssrlive
  • ssrlivebox(at)gmail(dot)com
View GitHub Profile
/* UDP echo server program -- udp-echo-server.c */
#include <stdio.h> /* standard C i/o facilities */
#include <stdlib.h> /* needed for atoi() */
#include <sys/types.h> /* system data type definitions */
#if defined(_WIN32)
#include <WinSock2.h>
#pragma comment(lib, "Ws2_32.lib")
#else
#include <unistd.h> /* defines STDIN_FILENO, system calls,etc */
/*
* udp-client.c - A simple UDP client
* usage: udp-client <host> <port>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#if defined(_WIN32)
#include <WinSock2.h>
;
; Definition file for the DLL version of the crypto library from mbedTLS
;
; LIBRARY mbedTLS
EXPORTS
mbedtls_aes_init
mbedtls_aes_free
#include <stdbool.h>
unsigned int get_digit_value(char digit) {
int n = digit - '0';
if (n >= 0 && n<10) { return (unsigned int) n; }
if ((digit == 'A') || (digit == 'a')) { return 10; }
if ((digit == 'B') || (digit == 'b')) { return 11; }
if ((digit == 'C') || (digit == 'c')) { return 12; }
if ((digit == 'D') || (digit == 'd')) { return 13; }
if ((digit == 'E') || (digit == 'e')) { return 14; }
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(_WIN32)
#include <WinSock2.h>
#include <ws2tcpip.h>
#pragma comment(lib, "Ws2_32.lib")
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(_WIN32)
#include <WinSock2.h>
#include <ws2tcpip.h>
#pragma comment(lib, "Ws2_32.lib")
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <uv.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
void uv_alloc_buffer(uv_handle_t *handle, size_t size, uv_buf_t *buf);
void uv_free_buffer(uv_buf_t *buf);
void client_accept_cb(uv_stream_t *server, int status);
void client_read_done_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);
void client_close_done_cb(uv_handle_t* handle);
# -*- coding: utf-8 -*-
# https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001432004374523e495f640612f4b08975398796939ec3c000#0
import socket, threading, time
#TCP socket based on ipv4
#server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#listening on port
# -*- coding:utf-8 -*-
import socket
#client
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#establish connection
s.connect(('35.199.116.57', 9999))
@ssrlive
ssrlive / ws_server_demo.c
Created June 4, 2019 18:15
WebSocket server demo
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <http_parser.h>
#include <inttypes.h>
#include <ctype.h>
#include <mbedtls/sha1.h>