Hello. I'm developing with MINA 1.1.1. (thanks to Trustin and dev)
I tested socket open/close of infinite loop with simple own protocol.
I think before test, client program will send request and receive
response to infinite loop. But, after 65536 loop, server is maybe
down? server cannot ack.
what's the problem?
Thanks.
[server main] - this is almost ImageServer example
public static void main( String[] args ) throws Throwable {
BasicConfigurator.configure();
IoAcceptor acceptor;
acceptor = new SocketAcceptor(
Runtime.getRuntime().availableProcessors() + 1,
Executors.newCachedThreadPool() );
// Prepare the service configuration.
SocketAcceptorConfig cfg = new SocketAcceptorConfig();
cfg.setReuseAddress( true );
cfg.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new
ServerCodecFactory( SERVER ) ) );
acceptor.bind( new InetSocketAddress(
Configuration.getInstance().getServerPort() ), new
ServerSessionHandler( ), cfg );
}
--
[client]
import string
import sys
import struct
import time
import random
import string, time
from socket import *
def safesend( sock, pack, size):
left = size
cur = 0
while left:
ret = sock.send( pack );
if ret==-1:
return -1
if ret==0:
return cur
cur = cur + ret
left = left - ret
return cur
i = 0
while 1 :
serverHost = 'xxx.xxx.xxx.xxx'
serverPort = xxxxx
c = socket( AF_INET, SOCK_STREAM )
c.connect( (serverHost, serverPort) )
rev = ""
pA = 0xAA
pB = 0x01
pC = 0x00
pD = 0x00
pE = 0x00
pF = 0x00
format = "!B B B i B B"
safesend( c, struct.pack( format, pA, pB, pC, pD, pE, pF ),
struct.calcsize( format ) )
try :
rev = c.recv( 1024 )
temp = struct.unpack( "!BBBiBBH", rev )
except :
print "error"
c.close()
print i
i = i + 1
--