flat assembler
Message board for the users of flat assembler.

Index > Windows > any advice for this winsock server idea

Author
Thread Post new topic Reply to topic
sleepsleep



Joined: 05 Oct 2006
Posts: 8900
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
hi guys, =)

i was thinking something like below, and i need advice,

1. i want a winsock server that would accept connection, start timing the socket, FD_READ, FD_WRITE would reset the socket timer to 0 back, i want to close or force close the socket if timer exceed 10 seconds.

2. i am using WSAAsyncSelect atm, my target connection is around 10 socket, if the client start with KEEPALIVE string, i will not disconnect the socket, but every 10 seconds, i will send something to client, and client calculate it and send back answer to me, if no answer receive in another 5 seconds, i will force close the socket.

please advice me, thank you.
Post 17 Feb 2013, 12:20
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17278
Location: In your JS exploiting you and your system
revolution
Is this a public or private network? If it is public then five or ten seconds might not be enough to account for connection delays.
Post 17 Feb 2013, 12:25
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8900
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
private network, (i will use nginx on openbsd) for incoming public connection,

the idea for such server because i want to easily call dll function from local application ajax request.

some sort of HTA application on client side.
Post 17 Feb 2013, 13:04
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
Using time for controlling something is always wrong!

(I should print this statement on cards and give one to every engineer and programmer I know. It will spare me a lot of speaking. Smile )
Post 17 Feb 2013, 13:05
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8900
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
JohnFound wrote:
Using time for controlling something is always wrong!

(I should print this statement on cards and give one to every engineer and programmer I know. It will spare me a lot of speaking. Smile )


why?
what should we do with idle connection? in your opinion if not time based idle checking?
Post 17 Feb 2013, 14:19
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
I am not sure I understand what you mean, but if the connection is still connected, it means there is another application running on the other side, so you should not disconnect at all. At least not by time.

Also, if you read my statement properly, I didn't said you should not use time based control.
I said that it is always wrong. But we can write wrong applications of course. Wink
Post 17 Feb 2013, 14:30
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
There are some cases where an open connection is not desired.
Like the case of online banking.
User did his/her banking online, but got called from a computer for a few hrs and forgot to close the session.
I think that connection should time out in a few minutes of no activity.
Post 17 Feb 2013, 14:48
View user's profile Send private message Send e-mail Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8900
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
yeap, the client is connected, but i set my own protocol that if it is my client (those who able to answer my sent question and return back answer) i will not close them, or those who init connection with KEEPALIVE string and some number

but for those that accidentally connected (or people who just like to sabotage the server or DDOS it) i want to close them asap,

assume my server is able to pool only about 1000 socket, but DDOS will make the server unavailable, those socket will idle and hog up the pool.

i assume what i did is correct but of course, i open to any advice,
Post 17 Feb 2013, 14:49
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
If we are talking about web server - you can always close the connection after the current request is finished. The same is true for the banking application AsmGuru62 talking about.

If you have pool of limited number of sockets, you can simply wait until this count is reached (or any other count) and then disconnect the socket that has longest idle state. This way you will always disconnect at the last possible moment and not by time but by events.
Post 17 Feb 2013, 17:24
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8900
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
JohnFound wrote:

If we are talking about web server - you can always close the connection after the current request is finished. The same is true for the banking application AsmGuru62 talking about.

ok, i understand,
Post 17 Feb 2013, 17:47
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.