Skip to main content

Posts

Showing posts with the label networking

MJPEG Streaming Protocol

MJPEG is a popular format for webcam streams. It's probably popular because it's so simple to do and the performance is surprisingly good. Unfortunately, I found it quite difficult to scrape together enough information to implement a streamer myself. In an effort to help the next poor, frustrated soul, here's a simple method for streaming an MJPEG to a socket in Java. public void handleConnection(Socket socket, JpegProvider jpegProvider) throws Exception { byte[] data = jpegProvider.getJpeg(); OutputStream outputStream = socket.getOutputStream(); outputStream.write(( "HTTP/1.0 200 OK\r\n" + "Server: YourServerName\r\n" + "Connection: close\r\n" + "Max-Age: 0\r\n" + "Expires: 0\r\n" + "Cache-Control: no-cache, private\r\n" + "Pragma: no-cache\r\n" + "Content-Type: multipart/x-mixed-replace; " + "boundary=--BoundaryString\r\n\r\n...
Read more

Ubuntu Jaunty Wireless and RT61PCI

I upgraded to Jaunty yesterday and again had to struggle with my wireless. This time, it wasn't necessary to install a new kernel module. Instead, I just needed to remove Network Manager and set up wpa_supplicant . Here's my new /etc/network/interfaces that I configured for my WPA2 PSK AES TLA network. auto wlan0 iface wlan0 inet dhcp wpa-driver wext wpa-conf managed wpa-ssid myssid wpa-ap-scan 1 wpa-proto RSN wpa-pairwise CCMP wpa-group CCMP wpa-key-mgmt WPA-PSK wpa-psk mypsk With that, all I needed to do was sudo /etc/init.d/networking restart .
Read more

SSH Tunnel to Router Settings

I always forget how to do this and it's extremely useful. If you have SSH access to your box behind your router, you can use a double SSH tunnel to connect to the router and adjust your settings. localhost$ ssh -L 8888:remotehost:8888 remotehost remotehost$ ssh -L 8888:router:443 localhost Now just point your localhost browser to https://localhost:8888/.
Read more

Finding your public IP address in Python

I came across a nice code snippet today to accomplish this. Naturally, this doesn't work for NAT. def GetPublicIpAddress(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('google.com', 80)) return s.getsockname()[0] Another great snippet for finding the IP address of a given network interface is in the ASPN Python Cookbook .
Read more