This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <netinet/in.h> | |
#include <string.h> | |
#define PORT_NO 4545 | |
#define BUFFER_SIZE 1024 | |
int main(int argc, char *argv[]) { | |
int sd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/asio/coroutine.hpp> | |
#include <boost/asio/local/connect_pair.hpp> | |
#include <boost/asio/local/stream_protocol.hpp> | |
#include <iostream> | |
#include <sys/wait.h> | |
std::size_t | |
send_fd(boost::asio::local::stream_protocol::socket& socket, | |
int fd, | |
boost::system::error_code& ec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <signal.h> | |
#include <syslog.h> | |
#include <errno.h> | |
#include <stdlib.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compile with gcc -static -o recvfd recvfd.c | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <sys/un.h> | |
#include <strings.h> | |
static int recv_fd(int sock){ | |
// This function does the arcane magic recving | |
// file descriptors over unix domain sockets | |
struct msghdr msg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compile with: gcc -static -o sendfd sendfd.c | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <sys/un.h> | |
#include <strings.h> | |
int send_fd(int sock, int fd){ | |
// This function does the arcane magic for sending | |
// file descriptors over unix domain sockets | |
struct msghdr msg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ev.h> | |
#include <unistd.h> | |
#include <stdio.h> // for puts | |
// every watcher type has its own typedef'd struct | |
// with the name ev_TYPE | |
ev_io stdin_watcher; | |
ev_timer timeout_watcher; | |
// all watcher callbacks have a similar signature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* echo-server.cpp | |
* echo server with libev | |
* | |
* g++ -std=c++11 -Wall -Wextra -pedantic -lev timer.cpp | |
* | |
* telnet localhost 40713 | |
* | |
* written by janus_wel<[email protected]> | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* test_libv.c | |
* | |
* Created on: May 30, 2014 | |
* Author: damonhao | |
*/ | |
// a single header file is required | |
#include <ev.h> | |
#include <stdio.h> // for puts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Licensed under the Apache License, Version 2.0. | |
* | |
* simple libev client example | |
* based on multi-process and ring buffer | |
* [email protected] | |
*/ | |
/* | |
gcc ./libev-client.c -c -o ./libev-client.o -I/usr/local/include/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <uv.h> | |
#include <curl/curl.h> | |
uv_loop_t *loop; | |
CURLM *curl_handle; | |
uv_timer_t timeout; | |
typedef struct curl_context_s { |
NewerOlder