473,569 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Seralisation the final question

Hi

i want to be able to check if information read that came from over a socket
is serilisable, if it isnt i want to handle it differently. Basically i am
trying to make a generic receivedata function that i can send any form of
data over the wire too and it will handle it appropriately.

I know i could do a try catch on a serilisation exception but i dont think
this is a good way to check as other things could cause such an error.

I did think of writing into the first 4 bytes of the send stream an
indenitifier for the response, then the slient can read those bytes and
decide, but again it starts to become less generic. Ideally i would like
anyone to send any info and i can handle it

Any ideas?

Also i am stuck on a scenario where i send data and cant proceed until i get
a response. One of my functions on the client fires a request but if the
client continues before getting a response it will crash. If i get it to
wait i end up poling and everything freezes for a second. I was thinking of
moving my interface logic and my actual application logic to 2 separate
threads. Then i can make the app logic wait while the sent message waits for
a reply, meanwhile the interface thread continues and i get no apparent
freeze. But i am sure this is not good for performance or is this ok?

thanks
Feb 11 '06 #1
3 1343
Daniel,

I would consider your objects to be messages. Either that, or you have
a wrapper object that has a reference to the object being serialized, as
well as any other information that needs to be sent along (like the status
code).

Then, you would send the length across the wire first, so you know how
many bytes to read.

With serialization, you just need a byte array that represents the
serialized instant. It doesn't matter wha the transport mechanism is.

I would also recommend having each of those types implement an interface
which will make accessing the objects in a consistent way easier.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Daniel" <Da*****@vestry online.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi

i want to be able to check if information read that came from over a
socket is serilisable, if it isnt i want to handle it differently.
Basically i am trying to make a generic receivedata function that i can
send any form of data over the wire too and it will handle it
appropriately.

I know i could do a try catch on a serilisation exception but i dont think
this is a good way to check as other things could cause such an error.

I did think of writing into the first 4 bytes of the send stream an
indenitifier for the response, then the slient can read those bytes and
decide, but again it starts to become less generic. Ideally i would like
anyone to send any info and i can handle it

Any ideas?

Also i am stuck on a scenario where i send data and cant proceed until i
get a response. One of my functions on the client fires a request but if
the client continues before getting a response it will crash. If i get it
to wait i end up poling and everything freezes for a second. I was
thinking of moving my interface logic and my actual application logic to 2
separate threads. Then i can make the app logic wait while the sent
message waits for a reply, meanwhile the interface thread continues and i
get no apparent freeze. But i am sure this is not good for performance or
is this ok?

thanks

Feb 11 '06 #2

"Daniel" <Da*****@vestry online.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi

i want to be able to check if information read that came from over a
socket is serilisable, if it isnt i want to handle it differently.
Basically i am trying to make a generic receivedata function that i can
send any form of data over the wire too and it will handle it
appropriately.

I know i could do a try catch on a serilisation exception but i dont think
this is a good way to check as other things could cause such an error.

I did think of writing into the first 4 bytes of the send stream an
indenitifier for the response, then the slient can read those bytes and
decide, but again it starts to become less generic. Ideally i would like
anyone to send any info and i can handle it

Any ideas?
It can't really be "generic" -- it can only handle the instances for which
you anticipate and senders agree to.
You need to send the length with any message (this is a stream), and I'd go
for the ID over the partial-read and expection, especially if your data can
be large, so that you can keep pending data in stream format, so consumers
that can take it this way are able to. If your data is mostly small, you can
read it using the length into a buffer and use your trial/error approach -
chances are derialzation will fail very quickly - although of course,
there's always a chance it will not fail at all - dangerous.

If you want to be more expressive, maybe you should go for a string (which
could even be XML someday) for the message identifier rather than an int --
for instance, you could send the name of a class to use to deserialize your
data on the other side, and use refection or a factory on the other side to
create the proper de-serializer instance. Versioning could be up to you in
your message preamble, or handled by each serialization protocol itself.

m

Also i am stuck on a scenario where i send data and cant proceed until i
get a response. One of my functions on the client fires a request but if
the client continues before getting a response it will crash. If i get it
to wait i end up poling and everything freezes for a second. I was
thinking of moving my interface logic and my actual application logic to 2
separate threads. Then i can make the app logic wait while the sent
message waits for a reply, meanwhile the interface thread continues and i
get no apparent freeze. But i am sure this is not good for performance or
is this ok?

thanks

Feb 11 '06 #3
All the native types (i.e. string, int, etc) can be serialize and any type
that has [Serializable] attribute. That is pretty generic. If you just
want to send a string, then serialize the string and send it. So your
"contract" can be anything serializable can be sent as long as you have the
proper type and version on the server side. If you can't deserialize it,
then there is not much you could do with the type anyway except log it and
close the client connection. What do you plan to do with types you don't
have a type for? Just curious.

--
William Stacey [MVP]

"Daniel" <Da*****@vestry online.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
| Hi
|
| i want to be able to check if information read that came from over a
socket
| is serilisable, if it isnt i want to handle it differently. Basically i am
| trying to make a generic receivedata function that i can send any form of
| data over the wire too and it will handle it appropriately.
|
| I know i could do a try catch on a serilisation exception but i dont think
| this is a good way to check as other things could cause such an error.
|
| I did think of writing into the first 4 bytes of the send stream an
| indenitifier for the response, then the slient can read those bytes and
| decide, but again it starts to become less generic. Ideally i would like
| anyone to send any info and i can handle it
|
| Any ideas?
|
| Also i am stuck on a scenario where i send data and cant proceed until i
get
| a response. One of my functions on the client fires a request but if the
| client continues before getting a response it will crash. If i get it to
| wait i end up poling and everything freezes for a second. I was thinking
of
| moving my interface logic and my actual application logic to 2 separate
| threads. Then i can make the app logic wait while the sent message waits
for
| a reply, meanwhile the interface thread continues and i get no apparent
| freeze. But i am sure this is not good for performance or is this ok?
|
| thanks
|
|
Feb 13 '06 #4

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

Similar topics

1
3434
by: Anthony Martin | last post by:
I've been reading the Java Language Specification, and in Chapter 16 there's an interesting topic called Definite Assignment. http://tinyurl.com/3fqk8 I'm wondering about the idea of "Deferred Final Automatic Variables" like the following: void unflow(boolean flag) { final int k;
14
23111
by: Medi Montaseri | last post by:
Hi, I think my problem is indeed "how to implement something like java's final in C++" The long version.... I have an abstract base class which is inherited by several concrete classes. I have a group of methods that I'd like to implement in the base class
0
1808
by: Hans Forbrich | last post by:
Section 1. Ballot: ------------------- 1.YES NO: I agree that there should be a periodic post describing the newsgroup charter and providing a FAQ on newsgroup usage. 2.MONTHLY BI-WEEKLY WEEKLY: The post should be transmitted with this frequency.
10
5098
by: Bezalel Bareli | last post by:
I know I have seen some threads on the subject long time ago and it was using a virtual base class ... in short, what is the nicest way to implement the Java final class in c++ Thanks.
14
1758
by: My4thPersonality | last post by:
Has the fact that both Java and C# are garbage collected, and C++ in not, anything to do with the fact that there is no language item to prevent a class from being inherired from? I once read that Java and C# implement this feature for preformance, but the C++ creators said it was not worse the effort. So because Java and C# are garbage...
7
1854
by: Csaba Gabor | last post by:
I feel like it's the twilight zone here as several seemingly trivial questions are bugging me. The first of the following three lines is a syntax error, while the last one is the only one that shows the alert. What is the essential reason? function () { alert('hi mom'); }(); function () { alert('hi dad'); }(8); var x=function () {...
16
3505
by: TT (Tom Tempelaere) | last post by:
Hi all, I created an XSD to define the structure of an XML file for my project. I made an XML file linked to the XSD using XmlSpy. The problem is that if I read the file using .NET XmlDocument and then query for the root element, the result is always null (1). However if I strip the root element of all attributes generated by XmlSpy, then...
2
6719
by: Janick Bernet | last post by:
I recently learned about the "SELECT FROM NEW/OLD/FINAL TABLE" statement and I wanted to replace our old code, where we used "identity_val_local()" to get auto generated values after an insert. So I tried the following: #sql{ SELECT ID INTO :AssetEntryID
14
2959
by: Rahul | last post by:
Hi Everyone, I was searching for final class in c++, and i came across few links which suggests to have the constructor of the, to be final class, as private so that any derived class's constructors can't access the same. class C { private:
11
2247
by: ITrishGuru | last post by:
Hi all, I'm doing my FYP using csharp and MS Outlook to develope a plugin app. My question isn't about programming as such, Its more about project managment. Does anybody have a good URL that could inform me on how to appraoch a software development project? There are two of us on the project, we are not computer science students but Arts...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7619
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7682
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7984
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6290
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5515
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2119
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1230
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
954
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.