add net tests

This commit is contained in:
Roger Hughston 2006-11-07 00:58:31 +00:00
parent aa95cc3aff
commit 6164d1bf7e
3 changed files with 137 additions and 0 deletions

View File

@ -0,0 +1,38 @@
from libpandaexpress import BufferedDatagramConnection
from libpandaexpress import SocketAddress
from libpandaexpress import SocketIP
from libpandaexpress import SocketTCP
from libpandaexpress import SocketTCPListen
from libpandaexpress import SocketUDPOutgoing
from libpandaexpress import SocketUDPIncoming
SocketIP.InitNetworkDriver();
addr = SocketAddress()
addr.setHost("127.0.0.1",8080)
print addr.getIpPort()
inbound = SocketTCPListen()
inbound.OpenForListen(addr);
##inbound.SetNonBlocking();
while 1 == 1:
newsession = SocketTCP()
source = SocketAddress()
if inbound.GetIncomingConnection(newsession,source) :
#newsession.SetNonBlocking();
print source.getIpPort()
newsession.SendData("Hello From the Listener\n\r");
s = newsession.RecvData(10);
print s
print newsession.GetLastError()
if newsession.ErrorIsWouldBlocking(newsession.GetLastError()) :
print "Reading Would Block"
else:
print "Not A Blocking Error"
newsession.SendData("GoodBy From the Listener\n\r");
newsession.Close();

View File

@ -0,0 +1,49 @@
from libpandaexpress import BufferedDatagramConnection
from libpandaexpress import SocketAddress
from libpandaexpress import SocketIP
from libpandaexpress import SocketTCP
from libpandaexpress import SocketTCPListen
from libpandaexpress import SocketUDPOutgoing
from libpandaexpress import SocketUDPIncoming
from libpandaexpress import Datagram
import time
SocketIP.InitNetworkDriver();
addr = SocketAddress()
addr.setHost("127.0.0.1",6666)
print addr.getIpPort()
MyConection = BufferedDatagramConnection(0,4096000,4096000,102400);
#help(BufferedDatagramConnection)
MyConection.AddAddress(addr)
dg = Datagram();
dg.addUint8(1)
dg.addUint64(4001)
dg.addUint16(2001)
dg.addUint64(123456)
##MyConection.SendMessage(dg);
dg1 = Datagram();
dg1.addUint8(1)
dg1.addUint64(123456)
dg1.addUint64(12340)
dg1.addUint16(1000)
dg1.addUint16(54321)
while 1==1:
for x in range(200000):
if not MyConection.SendMessage(dg1):
print "Error Sending Message"
MyConection.Flush();
time.sleep(1)
print "loop"

View File

@ -0,0 +1,50 @@
from libpandaexpress import BufferedDatagramConnection
from libpandaexpress import SocketAddress
from libpandaexpress import SocketIP
from libpandaexpress import SocketTCP
from libpandaexpress import SocketTCPListen
from libpandaexpress import SocketUDPOutgoing
from libpandaexpress import SocketUDPIncoming
from libpandaexpress import Datagram
import time
SocketIP.InitNetworkDriver();
addr = SocketAddress()
addr.setHost("127.0.0.1",6666)
print addr.getIpPort()
MyConection = BufferedDatagramConnection(0,4096000,4096000,102400);
#help(BufferedDatagramConnection)
MyConection.AddAddress(addr)
dg = Datagram();
dg.addUint8(1)
dg.addUint64(4001)
dg.addUint16(2001)
dg.addUint64(123456)
MyConection.SendMessage(dg);
dg1 = Datagram();
dg1.addUint8(1)
dg1.addUint64(123456)
dg1.addUint64(12340)
dg1.addUint16(1000)
dg1.addUint16(54321)
while 1==1:
MyConection.SendMessage(dg);
##for x in range(120000):
while MyConection.GetMessage():
None
MyConection.Flush();
time.sleep(1)
print "loop"