CLASS TCP/IP LISTENER TRES SIMPLE ET MULTITHREAD DOTNET

Bodekaer Messages postés 3 Date d'inscription lundi 9 décembre 2002 Statut Membre Dernière intervention 12 décembre 2002 - 9 déc. 2002 à 11:19
lassad_haddaji Messages postés 141 Date d'inscription mardi 24 avril 2007 Statut Membre Dernière intervention 6 avril 2012 - 14 déc. 2008 à 13:37
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/4295-class-tcp-ip-listener-tres-simple-et-multithread-dotnet

lassad_haddaji Messages postés 141 Date d'inscription mardi 24 avril 2007 Statut Membre Dernière intervention 6 avril 2012
14 déc. 2008 à 13:37
manque de commentaire
demidali Messages postés 4 Date d'inscription jeudi 20 novembre 2003 Statut Membre Dernière intervention 7 octobre 2005
9 févr. 2005 à 22:49
Bonjour !

J'utilise les mêmes outils que vous pour avoir un service Windows qui écoute sur un port XXX. Ce service écoute sur un serveur Windows 2000. J'ai une application qui parle à ce service. La ligne de code networkstream.read(byte,0,...) retourne seulement le premier caractère de la chaine envoyé au service. Si je met le service sur un PC Windows XP, la string est complète sans changer aucune ligne de code ...

Pouvez-vous m'aider ou me référer. Je cherche depuis 2 semaines, je suis pas mal désespéré ...

Merci !
cs_mahhoura Messages postés 15 Date d'inscription vendredi 23 janvier 2004 Statut Membre Dernière intervention 25 août 2007
23 janv. 2004 à 16:08
Bonjour Monsieur il y a une Classe TCPListner qui fait tout ce boulot reste a organiser le travail de sockets en les insérant dans un arrayList par exemple et de cette façon ton prog pourra gérer un nombre assez géant de connexions
cs_zappy Messages postés 161 Date d'inscription mardi 19 juin 2001 Statut Membre Dernière intervention 10 avril 2007 2
6 mars 2003 à 08:11
Pas tout à fait.
cs_RayBan Messages postés 17 Date d'inscription jeudi 24 janvier 2002 Statut Membre Dernière intervention 9 juin 2004
5 mars 2003 à 20:51
Hi,

I am not sure, but there a TCPListener class in .Net, that do all the thing your code do...
cs_zappy Messages postés 161 Date d'inscription mardi 19 juin 2001 Statut Membre Dernière intervention 10 avril 2007 2
12 déc. 2002 à 11:51
I haven't that in VB.NET.

But i have a good link for C# programming sockets in a non-blocking mode.
http://www.codeproject.com/csharp/socketsincs.asp

Happy coding !
Bodekaer Messages postés 3 Date d'inscription lundi 9 décembre 2002 Statut Membre Dernière intervention 12 décembre 2002
12 déc. 2002 à 11:45
No problem, my french isn't that good either :)

Well, I was wondering if you had a good example of hw to use asynchronous sockets in VB.NET

My program will normally handle between 30-90 connections at the same time.

/Michael
cs_zappy Messages postés 161 Date d'inscription mardi 19 juin 2001 Statut Membre Dernière intervention 10 avril 2007 2
9 déc. 2002 à 11:31
Hi bodekaer,

I'm sorry, now i'm coding in C# and not in VB.NET.

You can use asynchronous sockets for betters performances without multi-threading (one thread / session is not good for a lot connections).

I have tested this code on my win2k : works with 5 connections without problem.

Happy coding !

ps: Sorry for my bad english :)
Bodekaer Messages postés 3 Date d'inscription lundi 9 décembre 2002 Statut Membre Dernière intervention 12 décembre 2002
9 déc. 2002 à 11:19
Hi,

I am currently using your code in a VB.NET app I have created.

But when ever a thread is runinng, the loop that checks for new messages, uses a lot of CPU.
I actually thought that the Application.Doevents, would prevent the code from using a lot of CPU. But it doesn't.

I am sure it although wont affect the performance of other programs, but it looks "wild" the my program looks like it is using 100% of the CPU (and I am using a 2.5 Ghz machine :)

Is there anything to do to prevent this ?

/Michael
Rejoignez-nous