A Socket is simply an interface to another Socket, on the same machine or
another machine in a network. There is nothing particularly special about
Sockets that makes the rules regarding using them synchronously or
asynchronously in an app any different than any other programming component.
A Socket sends and receives data. So, a synchronous Socket will send and
receive data and block while sending or receiving. An asynchronous Socket
will not block. So, if you think of the sending and receiving as if it were
a method of a class, when would you use a separate thread to call a method
of a class? That's right: when the method blocks execution for a long time,
and the app would work better if the method ran asynchronously. For example,
an email client will send and receive emails asynchronously, so that the
user can perform other tasks with it while it is doing so.
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
Hard work is a medication for which
there is no placebo.
"Ole" <ol*@blabla.com> wrote in message
news:u3**************@TK2MSFTNGP03.phx.gbl...
Hi again,
I'm still a bit confused about when to use sync or async socket
communication so I will descibe my needs instead - hoping someone will
comment:
I have a socket server on a CE device communicating with a socket client
on a PC. The server must be able to receive and handle data from the
client PC while transferring other data to the same client - sort of full
duplex.
How should I organize my program (sync or async)??
Thanks
Ole
"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:u4**************@TK2MSFTNGP03.phx.gbl... The main reason to use or not to use a sync socket is how your program is
coded and what else might need to happen on the user interface thread
(the thread that controls the display of forms, etc.) If your data
transfer code is executing is a *different* thread from this UI stuff,
I'd use a sync socket. If not, you'll probably *have* to use an async
socket to allow user interface processing and keep the user interface
responsive.
Paul T.
"Ole" <ol*@blabla.com> wrote in message
news:OM**************@TK2MSFTNGP03.phx.gbl... Hi,
I'm going to develop a socket communication between an instrument
(running CE 5.0 with Compact Fraework V2) and a PC. As the instrument
should only connect to one PC at a time I believe that the sync version
of the socket should be the easiest - or what??? (please tell if I'm
wrong).
Are there anyone who is able to point to a Server and Client example
code in C# VS2005 (I've only been able to find a C++ version) ???
Thanks
Ole