Skip to content

Instantly share code, notes, and snippets.

View SummitXY's full-sized avatar
🚄
喜提和谐号

QuXiangyu SummitXY

🚄
喜提和谐号
View GitHub Profile
@SummitXY
SummitXY / epoll_client.c
Created May 8, 2022 15:52
使用C原生Epoll接口实现client
#include <stdio.h>    
#include <sys/types.h>    
#include <sys/socket.h>    
#include <netinet/in.h>    
#include <arpa/inet.h>    
#include <string.h>  
#include <stdlib.h>  
  
#define BUFFER_SIZE 40  
  
@SummitXY
SummitXY / epoll_server.c
Last active June 14, 2022 12:51
用C原生epoll接口实现server(这个就是建立连接和可读可写都用的同一个socket)
#include <stdio.h>     
#include <sys/types.h>     
#include <sys/socket.h>     
#include <netinet/in.h>     
#include <arpa/inet.h>   
#include <stdlib.h>  
#include <string.h>  
#include <sys/epoll.h>  
 
#define BUFFER_SIZE 40  
@SummitXY
SummitXY / main.c
Last active May 8, 2022 15:26
用C的select api实现server
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@SummitXY
SummitXY / netpoll_server_demo.go
Last active May 8, 2022 15:43
字节跳动开源Epoll组件实现server
package wego
import (
"context"
"fmt"
"github.com/cloudwego/netpoll"
)
var eventloop netpoll.EventLoop
@SummitXY
SummitXY / io_multiplexing_epoll.go
Last active June 14, 2022 12:48
用Go的官方unix的epoll包实现server demo(只能在Linux下跑, 不能在Mac下跑)
package main
import (
"fmt"
"golang.org/x/sys/unix"
)
var (
PORT = 9874
@SummitXY
SummitXY / io_nonblocking.go
Last active September 23, 2021 10:30
Unix API for Socket Server Demo (Nonblocking IO for every socket)
package main
import (
"fmt"
"syscall"
"time"
"golang.org/x/sys/unix"
)
@SummitXY
SummitXY / io_nonblocking_only_listener.go
Last active September 26, 2021 12:46
Unix API for Socket Server Demo (Nonblocking IO for listener)
package main
import (
"fmt"
"syscall"
"time"
"golang.org/x/sys/unix"
)
@SummitXY
SummitXY / io_blocking.go
Last active September 23, 2021 10:31
Unix API for Socket Server demo (Blocking IO)
package main
import (
"fmt"
"golang.org/x/sys/unix"
)
var (
PORT = 9874