In this module you’ll find all the network related implementation
New in version 0.6: The Network module.
The Broadcast UDP client thread class.
This class is a thread to serve as Pyevolve client on the UDP datagrams, it is used to send data over network lan/wan.
>>> s = Network.UDPThreadClient('192.168.0.2', 1500, 666)
>>> s.setData("Test data")
>>> s.start()
>>> s.join()
| Parameters: |
|
|---|
Get the data to send
| Return type: | data to send |
|---|
Returns the number of sent bytes. The use of this method makes sense when you already have sent the data
| Return type: | sent bytes |
|---|
Set the data to send
| Parameter: | data – the data to send |
|---|
The UDP server thread class.
This class is a thread to serve as Pyevolve server on the UDP datagrams, it is used to receive data from network lan/wan.
>>> s = UDPThreadServer("192.168.0.2", 666, 10)
>>> s.start()
>>> s.shutdown()
| Parameters: |
|
|---|
Note
this thread implements a pool to keep the received data, the poolSize parameter specifies how much individuals we must keep on the pool until the popPool method is called; when the pool is full, the sever will discard the received individuals.
Gets the current receive buffer size
| Return type: | integer |
|---|
Calls the socket recvfrom method and waits for the data, when the data is received, the method will return a tuple with the IP of the sender and the data received. When a timeout exception occurs, the method return None.
| Return type: | tuple (sender ip, data) or None when timeout exception |
|---|
Returns True when there is data on the pool or False when not
| Return type: | boolean |
|---|
Returns the size of the pool
| Return type: | integer |
|---|
Return the last data received on the pool
| Return type: | object |
|---|
Sets the receive buffer size
| Parameter: | size – integer |
|---|
The Unicast UDP client thread class.
This class is a thread to serve as Pyevolve client on the UDP datagrams, it is used to send data over network lan/wan.
>>> s = Network.UDPThreadClient('192.168.0.2', 1500)
>>> s.setData("Test data")
>>> s.setTargetHost('192.168.0.50', 666)
>>> s.start()
>>> s.join()
| Parameters: |
|
|---|
Set the data to send
| Parameter: | data – the data to send |
|---|
Returns True when there is data on the pool or False when not
| Return type: | boolean |
|---|
Returns the size of the pool
| Return type: | integer |
|---|
Return the last data received on the pool
| Return type: | object |
|---|
Send the data
| Parameter: | data – the data to send |
|---|---|
| Return type: | bytes sent to each destination |
Sets multiple host/port targets, the destinations
| Parameter: | address_list – a list with tuples (ip, port) |
|---|
Set the host/port of the target, the destination
| Parameters: |
|
|---|
Note
the host will be ignored when using broadcast mode
Return all the IPs from current machine.
>>> Util.getMachineIP()
['200.12.124.181', '192.168.0.1']
| Return type: | a python list with the string IPs |
|---|
Pickles the object and compress the dumped string with zlib
| Parameters: |
|
|---|
Decompress a zlib compressed string and unpickle the data
| Parameter: | obj – the object to be decompressend and unpickled |
|---|