Skip to content

Instantly share code, notes, and snippets.

@lemoce
lemoce / libevent_example.c
Created September 13, 2018 20:44
example of libevent
/*
https://stackoverflow.com/questions/11990700/broken-pipe-epipe-on-connection-to-loopback-address/12068942#12068942
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
/* Required by event.h. */
#include <stdio.h>
#include <stdlib.h>
void aux_func(int n, char * buf, int radix, int i, int *len) {
int q = n / radix;
int r = n % radix;
if (q < radix && q >=0 ) {
*len = i + 2;
*(buf+1) = r + '0';
@lemoce
lemoce / Teste.java
Created April 14, 2018 05:11
Multithread Echo Server
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.net.Socket;
import java.net.ServerSocket;
import java.util.List;
import java.util.LinkedList;