Skip to content

Instantly share code, notes, and snippets.

View limboinf's full-sized avatar
🎯
Focusing

limbo limboinf

🎯
Focusing
View GitHub Profile
//
// main.c
// C_lang
//
// Created by 方朋 on 16/4/21.
// Copyright © 2016年 方朋. All rights reserved.
//
#include <sys/socket.h>
#include <sys/types.h>
@limboinf
limboinf / unievent.cpp
Created May 11, 2016 03:11
统一事件源
//统一事件源
#include <unistd.h>
#include <stdio.h>
#include <sys/epoll.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
@limboinf
limboinf / convert_ipv4_address.py
Created May 11, 2016 06:21
Python IPv4 Address Convert.
# coding=utf-8
"""
desc..
:copyright: (c) 2015 by fangpeng.
:license: MIT, see LICENSE for more details.
"""
import socket
from binascii import hexlify # 以十六进制表示二进制数据
@limboinf
limboinf / socket_err.py
Created May 11, 2016 06:48
Python 优雅的处理套接字错误
# coding=utf-8
"""
优雅的处理套接字错误
socket.error
:copyright: (c) 2015 by fangpeng.
:license: MIT, see LICENSE for more details.
"""
__date__ = '15/10/22'
import sys
import socket
@limboinf
limboinf / get_set_socket_send_recv_buf.c
Created May 11, 2016 07:59
C 查看和设置接收和发送缓冲区大小
#include <sys/socket.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <assert.h>
int main(int argc, char **argv)
{
int err = -1; //返回值
@limboinf
limboinf / modify_socket_buff_size.py
Created May 11, 2016 08:10
Python 修改套接字发送和接收的缓冲区大小
# coding=utf-8
"""
修改套接字发送和接收的缓冲区大小
setsockopt()设置缓冲区大小,接收三个参数:level, optname, value
:copyright: (c) 2015 by fangpeng.
:license: MIT, see LICENSE for more details.
"""
__date__ = '15/10/22'
import socket
@limboinf
limboinf / resue_socket_addr.py
Last active May 11, 2016 08:53
Python 重用套接字地址
# coding=utf-8
"""
重用套接字地址(这个在网络编程中很重要)
:copyright: (c) 2015 by fangpeng.
:license: MIT, see LICENSE for more details.
"""
__date__ = '15/10/22'
import socket
@limboinf
limboinf / simple_echo_server.py
Created May 11, 2016 09:32
Python 一个简单的回射服务器
# coding=utf-8
"""
一个简单的回射服务器
这里是服务端代码
:copyright: (c) 2015 by fangpeng.
:license: MIT, see LICENSE for more details.
"""
__date__ = '15/10/22'
import socket
@limboinf
limboinf / simple_echo_client.py
Created May 11, 2016 09:33
Python 简单的回显服务器
# coding=utf-8
"""
echo client
:copyright: (c) 2015 by fangpeng.
:license: MIT, see LICENSE for more details.
"""
__date__ = '15/10/24'
import socket
import sys
@limboinf
limboinf / Fork_MixIn_server.py
Created May 11, 2016 13:08
在套接字服务器中使用ForkingMixIn类
# coding=utf-8
"""
在套接字服务器中使用ForkingMixIn类
:copyright: (c) 2016 by fangpeng(@beginman.cn).
:license: MIT, see LICENSE for more details.
"""
import os
import socket
import threading
import SocketServer