473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Best way to do a connection-oriented Send/Receive.

Hi all,

I've a message object that is serialized to a xml string and communicating
between a client and server with a connection-oriented (TCP) socket. Unlike
a UDP, in a TCP socket, the 'Receive' function will try to read in as much
data as possible from the buffer and return, and therefore, sometimes the
message isn't complete with just one 'Receive' call.

In order to make sure that my message is complete, I've added in a 'STX' and
'EOT' into my xml string just to make sure that whether if more than 1
'Receive' call is needed to complete the message. It definitely works, but
I'm just wondering if there is any other smarter way of doing it? Is it
possible do it like the UDP's 'receivefrom' function where it will only
return when the whole datagram is received? I'm using VS2005 now, any new
tricks?

Thanks,
Simon
Jan 26 '06 #1
6 2069
Simon,

The smartest way is probably using a webservice that collects your data.

(What is very easy to make using VB.Net 2005)

Just my thought,

Cor
Jan 26 '06 #2
It sounds good if mine is a web application. However, my is a Windows
application. Will it still works?
--Simon

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Simon,

The smartest way is probably using a webservice that collects your data.

(What is very easy to make using VB.Net 2005)

Just my thought,

Cor

Jan 26 '06 #3
Simon,

Have a look at this sample to get some ideas.

http://msdn.microsoft.com/library/de...alkthrough.asp

I hope this helps,

Cor
Jan 26 '06 #4
Hi Simon,

There are three common approaches to know when a message is complete:

- Use a delimiter (your approach)
- Use a message header (2 bytes, for example) to inform about of the length
of the message.
- Use fixed-length messages

With either approach you will need to loop in the receiving code until the
message is complete, because there are several buffers involved.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Simon Says" <wi**********@hotmail.com> escribió en el mensaje
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi all,

I've a message object that is serialized to a xml string and communicating
between a client and server with a connection-oriented (TCP) socket.
Unlike a UDP, in a TCP socket, the 'Receive' function will try to read in
as much data as possible from the buffer and return, and therefore,
sometimes the message isn't complete with just one 'Receive' call.

In order to make sure that my message is complete, I've added in a 'STX'
and 'EOT' into my xml string just to make sure that whether if more than 1
'Receive' call is needed to complete the message. It definitely works, but
I'm just wondering if there is any other smarter way of doing it? Is it
possible do it like the UDP's 'receivefrom' function where it will only
return when the whole datagram is received? I'm using VS2005 now, any new
tricks?

Thanks,
Simon

Jan 26 '06 #5
thank .

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Simon,

Have a look at this sample to get some ideas.

http://msdn.microsoft.com/library/de...alkthrough.asp

I hope this helps,

Cor

Jan 27 '06 #6
But with XML data, is there any more efficient way of doing it? I'm looking
at some of the XML functions right now, and am exploring the
'CanDeserialize' function in the XML.Serialization namespace. Thinking of
putting all received message from the socket into a stream, and keep
checking if 'CanDeserialize' return true. If the message is not complete,
then 'CanDeserialize' will return false on the stream.

Any pointers?
"Carlos J. Quintero [VB MVP]" <ca*****@NOSPAMsogecable.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Simon,

There are three common approaches to know when a message is complete:

- Use a delimiter (your approach)
- Use a message header (2 bytes, for example) to inform about of the
length of the message.
- Use fixed-length messages

With either approach you will need to loop in the receiving code until the
message is complete, because there are several buffers involved.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Simon Says" <wi**********@hotmail.com> escribió en el mensaje
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi all,

I've a message object that is serialized to a xml string and
communicating between a client and server with a connection-oriented
(TCP) socket. Unlike a UDP, in a TCP socket, the 'Receive' function will
try to read in as much data as possible from the buffer and return, and
therefore, sometimes the message isn't complete with just one 'Receive'
call.

In order to make sure that my message is complete, I've added in a 'STX'
and 'EOT' into my xml string just to make sure that whether if more than
1 'Receive' call is needed to complete the message. It definitely works,
but I'm just wondering if there is any other smarter way of doing it? Is
it possible do it like the UDP's 'receivefrom' function where it will
only return when the whole datagram is received? I'm using VS2005 now,
any new tricks?

Thanks,
Simon


Jan 27 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ryan N. | last post by:
Hello, I saw a brief blurb on this somewhere and am unable to recall where... In the context of Security, what are some best practices for handling -storing, locating, retrieving- database OLEDB...
6
by: Paul | last post by:
Hi. Just trying to find out the best approach as I beleive it might give me problems later on down the road. I have an ASP.NET application which references a shared database class which...
2
by: Steve | last post by:
Hi, I am a relatively new user to vs.NET, and currently developing a ASP.NET web site using MS access, with the view to moving it to SQLServer. My problem is, how do I set up the connection to...
51
by: bigHairy | last post by:
Hello. I have been teaching myself .NET over the last few months and have had some success. I would like to ask a question though... A number of examples I have followed have the following in...
5
by: darthghandi | last post by:
I've created a class to listen to all interfaces and do a BeginAccept(). Once it gets a connection, it passes the connected socket off and stores it in a List. Next, it continues to listen for...
3
by: Nemisis | last post by:
Guys, I would like to write a error handler, or something, that will allow me to write to a database when an error occurs on my site. I am trying to implement this in the global.asax file a the...
3
by: Venkat | last post by:
Hi, We have a windows application developed in c# and SQL Server 2005. Our application need to execute more than one command (ExecuteReader and ExecuteScalar) at a single time. Till now we have...
1
by: oaklander | last post by:
What is the best way to connect to a database in Java Class? I have used 3 different ways and would like to know what is the most efficient one. 1- Put the connection as a data member: ...
4
by: laziers | last post by:
Hi there Anybody knows what is the best way to manage creation 2000 of the database connections at the same time? Now Im doing it somethink like this: using ( Connection conn =...
4
by: trullock | last post by:
Hi, Can anyone suggest the best way to go about the following... I'm tracking clicks (mouse down x,y coordinates) on a web page by using some javascript to create an XHR which sends the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.