Jump to content

Check out our Community Blogs


Member Since 06 Mar 2009
Offline Last Active Aug 30 2009 05:48 AM

Posts I've Made

In Topic: WPA-PSK in Linux

27 August 2009 - 03:29 AM

Linux does indeed support this, it's really a matter if the driver Linux is using for your wireless card supports WPA*
A lot of modern distro's come with wpa_supplicant to help you to connect to WPA secured networks.
Here's an example wpa_supplicant config file.

# WPA protected network, supply your own ESSID and WPAPSK here:
  pairwise=CCMP TKIP
  group=CCMP TKIP WEP104 WEP40

Then you can do this to obtain a connection to the network specified in the config
bash-3.1$ su
bash-3.1# wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf > /dev/null &
[1] 11419      #-D specifies the driver, -i specifies the interface
bash-3.1# dhclient wlan0
wmaster0: unknown hardware address type 801
wmaster0: unknown hardware address type 801
Listening on LPF/wlan0/00:00:00:00:00:00
Sending on   LPF/wlan0/00:00:00:00:00:00
Sending on   Socket/fallback
DHCPREQUEST on wlan0 to port 67
bound to -- renewal in 227794 seconds.
:D Or you can take make it much easy for yourself and use wicd

In Topic: Battery Status

27 August 2009 - 03:03 AM

Here some python code that uses dbus/HAL to connect to your laptops ac_adapter and receives a signal when it's unplugged/plugged in.
Maybe you can try to port it to C++, I'm sure there is dbus/gobject header files for C++?

import gobject
import dbus, dbus.service, dbus.mainloop.glib

def on_device_event (arg, dbarry):
    if dev.GetProperty ('ac_adapter.present'):
        print "Battery is charging"
        print "Battery is discharging"

dbus.mainloop.glib.DBusGMainLoop (set_as_default=True)
bus = dbus.SystemBus ()
hal_obj = bus.get_object ('org.freedesktop.Hal', '/org/freedesktop/Hal/Manager')
hal = dbus.Interface (hal_obj, 'org.freedesktop.Hal.Manager')
dev_obj = bus.get_object("org.freedesktop.Hal", hal.FindDeviceByCapability("ac_adapter")[0])
dev = dbus.Interface(dev_obj, "org.freedesktop.Hal.Device")
dev.connect_to_signal("PropertyModified", on_device_event)

mainloop = gobject.MainLoop()

EDIT: Oh. A bit late of a reply, hopefully this is still helpful for him or someone else.

In Topic: New Here

01 August 2009 - 10:40 PM

Not to be rude, but did you have a question?

In Topic: Sockets

01 August 2009 - 10:32 PM

import socket

mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

mySocket.connect(("forum.codecall.net", 80))

mySocket.send("GET / HTTP/1.1\n")

mySocket.send("Host: forum.codecall.net\n\n")

text = ''

while 1:

    data = mySocket.recv(1024)

    text += data

    if not data: break



print text

In Topic: OOP vs Procedural

19 July 2009 - 05:14 AM

I do use OOP a bit, especially when creating GUI based applications OO is very handy.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download