Skip to content

Instantly share code, notes, and snippets.

@mike-zhang
mike-zhang / udpProxy.go
Created Oct 8, 2012
Implementation of a UDP proxy in Golang
View udpProxy.go
// Implementation of a UDP proxy
package main
import (
"flag"
"fmt"
"log"
"net"
"os"
@mike-zhang
mike-zhang / udpProxyServer.cpp
Created Oct 14, 2012
a simple udp proxy server (cpp code)
View udpProxyServer.cpp
/*
File : udpProxyServer.cpp
Author : Mike
E-Mail : Mike_Zhang@live.com
*/
#include <cstdlib>
#include <cstddef>
#include <iostream>
#include <string>
#include <boost/shared_ptr.hpp>
@mike-zhang
mike-zhang / tcpServer1.py
Created Sep 29, 2012
a simple tcp server (python code)
View tcpServer1.py
#! /usr/bin/python
# a simple tcp server
import socket,os
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('127.0.0.1', 12345))
sock.listen(5)
while True:
connection,address = sock.accept()
buf = connection.recv(1024)
print buf
@mike-zhang
mike-zhang / rtspTcpClient_DSS.py
Created Oct 29, 2012
rtsp TCP Client for DarwinStreamingServer(python)
View rtspTcpClient_DSS.py
#! /usr/bin/python
import socket,time,string,random,thread
m_Vars = {
"bufLen" : 1024 * 10,
"defaultServerIp" : "192.168.1.100",
"defaultServerPort" : 554,
"defaultTestUrl" : "rtsp://192.168.1.100/test1.mp4",
"defaultUserAgent" : "LibVLC/2.0.3 (LIVE555 Streaming Media v2011.12.23)"
View git_Backup.py
import os
'''
.ssh/config (windows,for local git server):
Host host100
Hostname 192.168.1.100
User git
IdentityFile C:/Users/admin/.ssh/id_rsa_gitBackup_host100
repo example:
@mike-zhang
mike-zhang / netfwd.go
Created Oct 8, 2012 — forked from wallrat/proxy.go
Simple GO TCP proxy
View netfwd.go
// can be run in go 1.0.3
// build : go build netfwd.go
package main
import (
"net"
"fmt"
"io"
"os"
)
@mike-zhang
mike-zhang / getIpList.py
Created Nov 12, 2012
获取网卡IP地址列表(Linux下python实现)
View getIpList.py
#! /usr/bin/python
'''
CentOS 6.2 + Python 2.6
'''
def getIpList():
import os
ipList = []
var = os.popen('ifconfig').read().split("\n\n")
for item in var:
@mike-zhang
mike-zhang / tcpClient1.py
Created Sep 29, 2012
a simple tcp client(python code)
View tcpClient1.py
#! /usr/bin/python
# a simple tcp client
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('127.0.0.1', 12345))
#sock.send('Test\n')
sock.send(raw_input("Please input : "))
print sock.recv(1024)
sock.close()
@mike-zhang
mike-zhang / udpClient1.py
Created Sep 29, 2012
a simple udp client (python code)
View udpClient1.py
#! /usr/bin/python
# a simple udp client
import socket,time,traceback
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
dstHost = ('192.168.1.100', 12345)
while True:
try:
client.sendto('3',dstHost)
print time.time(),' : send success'
@mike-zhang
mike-zhang / udpServer1.py
Created Sep 29, 2012
a simple udp server (python code)
View udpServer1.py
#! /usr/bin/python
# a simple udp server
import socket, traceback
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(("127.0.0.1",12345))
while 1:
try: