O
OneMustFall
Reciently i wrote a simple client (in twisted) using Reconnecting
Factory.
That client logins to my socket server.. and that`s it.
Interesting thing is that it is seems that twisted client,
sends some ping on a TCP level without sending any data to the
socket directly.
Because when i pull out cord from the ethernet card simulating
network falure, client in about 10-15 seconds determines that
connection lost!! (pretty cool)
While my server thinks that client is connected.
I know that sockets ware designed to behave so.. to be tolarate
to
network problems, but in my case this is bad.. i want it to
behave like in twisted.
I have searched in a socketmodule.c from python source code for a
magic variables, but did not found anything that fits.
I am using SO_KEEPALIVE on server - but documentations says
it will only ping (and so timed outed) in a few hours.
How do i make my server act the same way as twisted client?
(to make some sort of a low level checking if a connections is
broken without actualy sending anything to socket)
The only suspicious lines intwisted is seems :
---------------------------------------------------------------------------
SO_UPDATE_ACCEPT_CONTEXT = 0x700B
SO_UPDATE_CONNECT_CONTEXT = 0x7010
--------------------------------------------------------------------------
try:
acc_sock.setsockopt(socket.SOL_SOCKET,
SO_UPDATE_ACCEPT_CONTEXT, struct.pack("I", handle))
except socket.error, se:
self.transport.acceptErr(ret, bytes)
else:
self.transport.acceptDone(acc_sock,
acc_sock.getpeername())
--------------------------------------------------------------------------
if have_connectex:
try:
sock.setsockopt(socket.SOL_SOCKET,
SO_UPDATE_CONNECT_CONTEXT, "")
except socket.error, se:
self.transport.connectErr(failure.Failure(error.ConnectError()))
self.transport.connectDone()
---------------------------------------------------------------------------
I tried this all but it trows an exeption and not working and also
i have no i idea what
SO_UPDATE_ACCEPT_CONTEXT , andSO_UPDATE_CONNECT_CONTEXT means.
Huh. Any Suggestions?
Factory.
That client logins to my socket server.. and that`s it.
Interesting thing is that it is seems that twisted client,
sends some ping on a TCP level without sending any data to the
socket directly.
Because when i pull out cord from the ethernet card simulating
network falure, client in about 10-15 seconds determines that
connection lost!! (pretty cool)
While my server thinks that client is connected.
I know that sockets ware designed to behave so.. to be tolarate
to
network problems, but in my case this is bad.. i want it to
behave like in twisted.
I have searched in a socketmodule.c from python source code for a
magic variables, but did not found anything that fits.
I am using SO_KEEPALIVE on server - but documentations says
it will only ping (and so timed outed) in a few hours.
How do i make my server act the same way as twisted client?
(to make some sort of a low level checking if a connections is
broken without actualy sending anything to socket)
The only suspicious lines intwisted is seems :
---------------------------------------------------------------------------
SO_UPDATE_ACCEPT_CONTEXT = 0x700B
SO_UPDATE_CONNECT_CONTEXT = 0x7010
--------------------------------------------------------------------------
try:
acc_sock.setsockopt(socket.SOL_SOCKET,
SO_UPDATE_ACCEPT_CONTEXT, struct.pack("I", handle))
except socket.error, se:
self.transport.acceptErr(ret, bytes)
else:
self.transport.acceptDone(acc_sock,
acc_sock.getpeername())
--------------------------------------------------------------------------
if have_connectex:
try:
sock.setsockopt(socket.SOL_SOCKET,
SO_UPDATE_CONNECT_CONTEXT, "")
except socket.error, se:
self.transport.connectErr(failure.Failure(error.ConnectError()))
self.transport.connectDone()
---------------------------------------------------------------------------
I tried this all but it trows an exeption and not working and also
i have no i idea what
SO_UPDATE_ACCEPT_CONTEXT , andSO_UPDATE_CONNECT_CONTEXT means.
Huh. Any Suggestions?