By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,971 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,971 IT Pros & Developers. It's quick & easy.

Help with sockets

P: n/a
Hi all,

as a VB.Net programmer I am finding it difficult to
find a text on implementing sockets to communicate
with an embedded web server.

Does anyone know of a good resource, either text book
or on-line that I should refer to. I also need to
implement multi-threading to enable me to communicate
with several embedded devices at the same time.

Many thanks,

Jason.
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Basically you have 3 options, from high level to low level:

- The WebClient class (since you are dealing with Web servers)

- The TcpClient class

- The Socket class: a raw managed wrapper to Winsock API.

The MSDN has documentation to learn about them. For actual samples, there
are a lot on the web. See, for example (although it is C# oriented, the .NET
framework classes are the important point):

http://www.c-sharpcorner.com/Networking.asp

Multithreading is a complex subject. The book of Dan Appleman "Moving to VB
..NET: Strategies, Concepts, and Code",
http://www.amazon.com/exec/obidos/tg...76827?v=glance,
has the best multithreading chapter that I have read about threading and its
issues.

--

Carlos J. Quintero (Visual Developer - .NET MVP)

The MZ-Tools all-in-one add-in, now for .NET: http://www.mztools.com
"Jason L James" <ja***@nospam.divemaster.org> escribió en el mensaje
news:6v********************************@4ax.com...
Hi all,

as a VB.Net programmer I am finding it difficult to
find a text on implementing sockets to communicate
with an embedded web server.

Does anyone know of a good resource, either text book
or on-line that I should refer to. I also need to
implement multi-threading to enable me to communicate
with several embedded devices at the same time.

Many thanks,

Jason.

Nov 21 '05 #2

P: n/a
Carlos,
thanks very much. I'll let you know how I get on. My .Net app
will need to multi-thread a TcpClient class to talk to multiple
embedded servers. Does this seem like it will be possible?

Thanks,

Jason.

On Thu, 21 Oct 2004 16:30:42 +0200, "Carlos J. Quintero [MVP]"
<ca*****@NOSPAMsogecable.com> wrote:
Basically you have 3 options, from high level to low level:

- The WebClient class (since you are dealing with Web servers)

- The TcpClient class

- The Socket class: a raw managed wrapper to Winsock API.

The MSDN has documentation to learn about them. For actual samples, there
are a lot on the web. See, for example (although it is C# oriented, the .NET
framework classes are the important point):

http://www.c-sharpcorner.com/Networking.asp

Multithreading is a complex subject. The book of Dan Appleman "Moving to VB
.NET: Strategies, Concepts, and Code",
http://www.amazon.com/exec/obidos/tg...76827?v=glance,
has the best multithreading chapter that I have read about threading and its
issues.


Nov 21 '05 #3

P: n/a
Sure, I am right now developing a multithreaded .NET app the uses the
TcpClient class to talk with a server using TCP/IP through multiple
connections, one for each thread, and it works fine. You can add some
Windows performance counters to see graphically the performance varying the
number of threads and impress your boss.

The idea is:

- You have a single instance of a Controller class which instanciates one or
more Processor objects and stores them in a collection.

- Each Processor class has internally its own Thread member variable, which
is set to execute a method of the class which contains a loop (in my case),
and its own TcpClient connection which is connected when the object is
created and before the thread is started.

- The Processor class exposes a Start method that starts its internal
thread.

- The Processor class exposes a Stop method, which internally sets a
variable to exit the loop.

- When the Controller wants to start or to stop the processors, it calls the
proper method on each instance of its collection of processors.

With this approach each thread runs code of a different Processor instance,
so you don´t have shared variables and write collisions.

I can´t send the code because I have written it in Spanish (and C#) but let
me know if you need more info.

--

Carlos J. Quintero (Visual Developer - .NET MVP)

The MZ-Tools all-in-one add-in, now for .NET: http://www.mztools.com
"Jason L James" <ja***@nospam.divemaster.org> escribió en el mensaje
news:cp********************************@4ax.com...
Carlos,
thanks very much. I'll let you know how I get on. My .Net app
will need to multi-thread a TcpClient class to talk to multiple
embedded servers. Does this seem like it will be possible?

Thanks,

Jason.

Nov 21 '05 #4

P: n/a
Carlos,

it sure sounds like you know what you are doing. This area of
VB (multi-threading and sqlClient objects) is very new to me. I have
a lot of learning to do but I am going to start slowly; firstly with
multi-threading and then add sockets once things are looking OK.
This news group thread will probably be removed from most news
servers before I have finished my application. However, if you
don't mind I should like to keep in touch via email (or this group)
to seek advise and suggestions from you as I progress.

Many thanks,

Jason.

On Fri, 22 Oct 2004 12:47:32 +0200, "Carlos J. Quintero [MVP]"
<ca*****@NOSPAMsogecable.com> wrote:
Sure, I am right now developing a multithreaded .NET app the uses the
TcpClient class to talk with a server using TCP/IP through multiple
connections, one for each thread, and it works fine. You can add some
Windows performance counters to see graphically the performance varying the
number of threads and impress your boss.

The idea is:

- You have a single instance of a Controller class which instanciates one or
more Processor objects and stores them in a collection.

- Each Processor class has internally its own Thread member variable, which
is set to execute a method of the class which contains a loop (in my case),
and its own TcpClient connection which is connected when the object is
created and before the thread is started.

- The Processor class exposes a Start method that starts its internal
thread.

- The Processor class exposes a Stop method, which internally sets a
variable to exit the loop.

- When the Controller wants to start or to stop the processors, it calls the
proper method on each instance of its collection of processors.

With this approach each thread runs code of a different Processor instance,
so you don´t have shared variables and write collisions.

I can´t send the code because I have written it in Spanish (and C#) but let
me know if you need more info.

--

Carlos J. Quintero (Visual Developer - .NET MVP)

The MZ-Tools all-in-one add-in, now for .NET: http://www.mztools.com
"Jason L James" <ja***@nospam.divemaster.org> escribió en el mensaje
news:cp********************************@4ax.com.. .
Carlos,
thanks very much. I'll let you know how I get on. My .Net app
will need to multi-thread a TcpClient class to talk to multiple
embedded servers. Does this seem like it will be possible?

Thanks,

Jason.



Nov 21 '05 #5

P: n/a
I didn´t knew anything about threads or .NET networking until 3 weeks ago,
but in .NET all this is very easy. Multithreading is difficult if threads
must share variables, but maybe you are not in that case.

So, post again if you need and feel free to e-mail me if I overlook your
messages (I spend more time in the vsnet newsgroups).
--

Carlos J. Quintero (Visual Developer - .NET MVP)

The MZ-Tools all-in-one add-in, now for .NET: http://www.mztools.com
"Jason L James" <ja***@no-spam.dive-master.org> escribió en el mensaje
news:41***************@news.demon.co.uk...
Carlos,

it sure sounds like you know what you are doing. This area of
VB (multi-threading and sqlClient objects) is very new to me. I have
a lot of learning to do but I am going to start slowly; firstly with
multi-threading and then add sockets once things are looking OK.
This news group thread will probably be removed from most news
servers before I have finished my application. However, if you
don't mind I should like to keep in touch via email (or this group)
to seek advise and suggestions from you as I progress.

Many thanks,

Jason.

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.