News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

multi-sockets

Started by WYVERN666, May 09, 2011, 08:41:13 PM

Previous topic - Next topic

WYVERN666

hi everyone,

I am wiriting (more exactly: trying to write) a server multi-threaded application but i have some doubs about this...

Can i have a specific buffer (specific vars) for every thread created??, I suposse not because memory is sheared in the application so ¿I need to declare in code segment something like buffer1 db 512 dup (0), buffer2 db 512 dup (0), buffer3 db 512 dup (0) and so on... ?, but i dont want a predefined numer of threads/sockets so y dont know how much buffers y need.

I can detect when the client closes connection when i get 0 in EAX from the "invoke recv", but is the only way?. I readed that using WSAAsyncSelect (non-bloking) can be notified about the CLOSE event, but this function is only for a GUI application?, i am not using this function because at the moment y have just a console app.

To have control on all the sockets i need something like an array of socket handles?

I think i need some client/server application examples., it will be good help.

baltoro

There is: Thread Local Storage (TLS),...although, for what you're doing, it's probably more trouble than it's worth.
Are you writing server/client,...as in, COM server/client ?
Baltoro

Slugsnack

This depends on the purpose of your client/server pair. It may well be better off for you to use a 'proper' server technology such as JSP, PHP, etc.

oex

Quote from: WYVERN666 on May 09, 2011, 08:41:13 PM
Can i have a specific buffer (specific vars) for every thread created??, I suposse not because memory is sheared in the application so ¿I need to declare in code segment something like buffer1 db 512 dup (0), buffer2 db 512 dup (0), buffer3 db 512 dup (0) and so on... ?, but i dont want a predefined numer of threads/sockets so y dont know how much buffers y need.

Create buffers *in the thread procs* with LOCAL variables (until you understand what you are doing)

Quote from: WYVERN666 on May 09, 2011, 08:41:13 PM
I can detect when the client closes connection when i get 0 in EAX from the "invoke recv", but is the only way?. I readed that using WSAAsyncSelect (non-bloking) can be notified about the CLOSE event, but this function is only for a GUI application?, i am not using this function because at the moment y have just a console app.

This depends on your protocol and the security reliability you assign to your server setup.... For anything mission crtical you should rely (at least as one indicator) to the feedback of recv

Quote from: WYVERN666 on May 09, 2011, 08:41:13 PM
To have control on all the sockets i need something like an array of socket handles?

I wont answer this part.... I got this wrong last time I replied through faded knowledge from writing server applications :lol.... I do remember some 'weirdness' with this on received connections but I'll leave that part to other more experienced processors :lol.... I write only client code right now and all my critical thinking pathways are constructed with only this knowledge :lol....

Quote from: WYVERN666 on May 09, 2011, 08:41:13 PM
I think i need some client/server application examples., it will be good help.

It would certainly be a good idea.... Search the forum there are some however remember that sockets code is probably the most dangerous code you can write.... Spend time being sure you understand how to make it safe from multiple examples and other resources....

Quote from: Slugsnack on May 09, 2011, 09:16:37 PM
a 'proper' server technology such as JSP, PHP, etc.

:lol.... but yes :bg
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

WYVERN666

thanks for your replies! :bg

Well... I learned java, php, ruby, other scripting stuf, etc and i am here now, i like all languages (OOP or not, low level or high level or whatever), maybe sometimes the sintaxyS sucks (for ex.: PHP xD). Programming is hobby for me so i dont have a boss that forces me to use some lang  :lol. I think i am not interested in the "productive programmer" paradigma wich needs more easy asbtract languages or need tools to make their job quick, i do this beacuse i like it and enjoy it.

I will check about "TLS", maybe that help me with the multi-thread model. But ¿can i use something like "WSAAsyncSelect,hSocket,hWind,WM_SOCKET,FD_ACCEPT + FD_CONNECT + FD_READ + FD_WRITE + FD_CLOSE" without a registered window?, the FD_CONNECT, FD_READ, etc, looks useful.

I have found server/client examples but single-threaded.