Sending entire objects via socket vs primitive message fields

I am using a library called "The Network Development Kit".
http://www.codeproject.com/internet/ndk.asp

The kit allows me to easily establish client/server connections and assemble
"messages" (consisting of strings, integers, etc) to pass back and forth
between the client and server.

With my initial protocol design, I have been passing data via the primitive
data field types (strings, int's, etc). The basic logic flow requires me to:
1) Deconstruct the object and assemble the varying field values into a
CNDKMessage.
2) Send that message to the server and reconstruct the object on the server
side.
3) Do some processing.
4) Deconstruct the object again assembling its different values into a
CNDMessage and send it back to the client.
5) The client then takes the message fields and recontructs the object with
the new values.

Within the message assembly class, there exists an interface that allows me
to send an entire object (LPVOID,UINT size).

This would make it much more convenient to just send the entire object
between the client/server without having to compose/decompose it's primitive
elements.

I don't see any troubles with this. But am I missing some design
considerations here? The only one that I can think of is that this may cause
troubles when producing a cross-platform client.  Serializing a "CObject" on
the windows side may not translate correctly within a Linux client.

How does everyone else generally do it? Do you usually just send the entire
object, or do you decompose your protocol into primitive types of integers
and strings?

Thanks in advance.


0
chase_jo (3)
7/20/2003 8:37:31 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
1640 Views

Similar Articles

[PageSpeed] 50

Joseph Chase wrote:
> 
> I am using a library called "The Network Development Kit".
> http://www.codeproject.com/internet/ndk.asp
> 
> The kit allows me to easily establish client/server connections and assemble
> "messages" (consisting of strings, integers, etc) to pass back and forth
> between the client and server.
> 
> With my initial protocol design, I have been passing data via the primitive
> data field types (strings, int's, etc). The basic logic flow requires me to:
> 1) Deconstruct the object and assemble the varying field values into a
> CNDKMessage.
> 2) Send that message to the server and reconstruct the object on the server
> side.
> 3) Do some processing.
> 4) Deconstruct the object again assembling its different values into a
> CNDMessage and send it back to the client.
> 5) The client then takes the message fields and recontructs the object with
> the new values.
> 
> Within the message assembly class, there exists an interface that allows me
> to send an entire object (LPVOID,UINT size).
> 
> This would make it much more convenient to just send the entire object
> between the client/server without having to compose/decompose it's primitive
> elements.
> 
> I don't see any troubles with this. But am I missing some design
> considerations here? The only one that I can think of is that this may cause
> troubles when producing a cross-platform client.  Serializing a "CObject" on
> the windows side may not translate correctly within a Linux client.
> 
> How does everyone else generally do it? Do you usually just send the entire
> object, or do you decompose your protocol into primitive types of integers
> and strings?
> 
> Thanks in advance.

Sending an entire object with (LPVOID, UINT size) is not usually
practical.  If the object contains any pointers then all this simple
approach does is send the pointers, not the "contained" data.  All
dynamically resizable container classes (vector, CString, ...) contain
pointers.

MFC contains a reasonably rich set of container classes that already
support serialization.  I.e. the MFC code will help compose/decompose
objects.

--
Scott McPhillips [VC++ MVP]
0
scottmcp (342)
7/21/2003 12:48:52 AM
Is it anything that derives from CObject, supports serialization?

Within my class, I have usage of CString, CMap<>, and CStringArray.  Are
these going to be supported?

Do the classes utilized within the CMap template have to support
serialization?

"Scott McPhillips" <scottmcp@mvps.org> wrote in message
news:3F1B3874.239C899B@mvps.org...
> Joseph Chase wrote:
> >
> > I am using a library called "The Network Development Kit".
> > http://www.codeproject.com/internet/ndk.asp
> >
> > The kit allows me to easily establish client/server connections and
assemble
> > "messages" (consisting of strings, integers, etc) to pass back and forth
> > between the client and server.
> >
> > With my initial protocol design, I have been passing data via the
primitive
> > data field types (strings, int's, etc). The basic logic flow requires me
to:
> > 1) Deconstruct the object and assemble the varying field values into a
> > CNDKMessage.
> > 2) Send that message to the server and reconstruct the object on the
server
> > side.
> > 3) Do some processing.
> > 4) Deconstruct the object again assembling its different values into a
> > CNDMessage and send it back to the client.
> > 5) The client then takes the message fields and recontructs the object
with
> > the new values.
> >
> > Within the message assembly class, there exists an interface that allows
me
> > to send an entire object (LPVOID,UINT size).
> >
> > This would make it much more convenient to just send the entire object
> > between the client/server without having to compose/decompose it's
primitive
> > elements.
> >
> > I don't see any troubles with this. But am I missing some design
> > considerations here? The only one that I can think of is that this may
cause
> > troubles when producing a cross-platform client.  Serializing a
"CObject" on
> > the windows side may not translate correctly within a Linux client.
> >
> > How does everyone else generally do it? Do you usually just send the
entire
> > object, or do you decompose your protocol into primitive types of
integers
> > and strings?
> >
> > Thanks in advance.
>
> Sending an entire object with (LPVOID, UINT size) is not usually
> practical.  If the object contains any pointers then all this simple
> approach does is send the pointers, not the "contained" data.  All
> dynamically resizable container classes (vector, CString, ...) contain
> pointers.
>
> MFC contains a reasonably rich set of container classes that already
> support serialization.  I.e. the MFC code will help compose/decompose
> objects.
>
> --
> Scott McPhillips [VC++ MVP]


0
chase_jo (3)
7/21/2003 2:29:03 PM
Archive your data to a CMemFile.
You are then able to read the memfile into buffers, send them, and 
recreate the memfile at the other end. You can then construct another 
CArchive from the memfile and read in the objects.

Joseph Chase wrote:

> Is it anything that derives from CObject, supports serialization?
> 
> Within my class, I have usage of CString, CMap<>, and CStringArray.  Are
> these going to be supported?
> 
> Do the classes utilized within the CMap template have to support
> serialization?
> 
> "Scott McPhillips" <scottmcp@mvps.org> wrote in message
> news:3F1B3874.239C899B@mvps.org...
> 
>>Joseph Chase wrote:
>>
>>>I am using a library called "The Network Development Kit".
>>>http://www.codeproject.com/internet/ndk.asp
>>>
>>>The kit allows me to easily establish client/server connections and
> 
> assemble
> 
>>>"messages" (consisting of strings, integers, etc) to pass back and forth
>>>between the client and server.
>>>
>>>With my initial protocol design, I have been passing data via the
> 
> primitive
> 
>>>data field types (strings, int's, etc). The basic logic flow requires me
> 
> to:
> 
>>>1) Deconstruct the object and assemble the varying field values into a
>>>CNDKMessage.
>>>2) Send that message to the server and reconstruct the object on the
> 
> server
> 
>>>side.
>>>3) Do some processing.
>>>4) Deconstruct the object again assembling its different values into a
>>>CNDMessage and send it back to the client.
>>>5) The client then takes the message fields and recontructs the object
> 
> with
> 
>>>the new values.
>>>
>>>Within the message assembly class, there exists an interface that allows
> 
> me
> 
>>>to send an entire object (LPVOID,UINT size).
>>>
>>>This would make it much more convenient to just send the entire object
>>>between the client/server without having to compose/decompose it's
> 
> primitive
> 
>>>elements.
>>>
>>>I don't see any troubles with this. But am I missing some design
>>>considerations here? The only one that I can think of is that this may
> 
> cause
> 
>>>troubles when producing a cross-platform client.  Serializing a
> 
> "CObject" on
> 
>>>the windows side may not translate correctly within a Linux client.
>>>
>>>How does everyone else generally do it? Do you usually just send the
> 
> entire
> 
>>>object, or do you decompose your protocol into primitive types of
> 
> integers
> 
>>>and strings?
>>>
>>>Thanks in advance.
>>
>>Sending an entire object with (LPVOID, UINT size) is not usually
>>practical.  If the object contains any pointers then all this simple
>>approach does is send the pointers, not the "contained" data.  All
>>dynamically resizable container classes (vector, CString, ...) contain
>>pointers.
>>
>>MFC contains a reasonably rich set of container classes that already
>>support serialization.  I.e. the MFC code will help compose/decompose
>>objects.
>>
>>--
>>Scott McPhillips [VC++ MVP]
> 
> 
> 

0
7/21/2003 9:03:34 PM
Reply:

Similar Artilces:

Debug Output Message
I am unsure what to do. I am receiving the following message: HEAP[NcicMdt.exe]: HEAP: Free Heap block ab4a50 modified at ab4a84 after it was freed This occurs during 'OnKillFocus' of a subclassed edit control: void ILclEdit::OnKillFocus() { if (m_ModifiedInd) { CString szTemp; GetWindowText(szTemp); <<=== This call MsgValidate(szTemp); } } The call stack is as follows: NTDLL! 77f75a58() NTDLL! 77f9d959() NTDLL! 77f83eb1() NTDLL! 77f589f2() _heap_alloc_base(unsigned int 64) line 200 _heap_alloc_dbg(unsigned int 22, int 1, const char * 0x5f4d0b18 THIS_FILE, int 118)...

Messages pending submission queue
We have exchange 2003 in a small native AD domain. Haven't long upgraded from exchange2000 and we're using GFI for anti spam. Just recently we've been having an intermittant problem whereby the messages pending submission queue fills up and the whole of exchange grinds to a halt. The SMTP service then cannot be re-started without rebooting the machine. This however has no effect on the queue. THe only way around it that we've found so far is to re-start the machine with the SMTP service disabled, remove the messages manually from the queue and then re-start the SMTP service. ...

producing a report via a keyword
help needed please........ I am not a formula expert so bear with me please. I know filtering is available but I am trying to save effort as data goes into a seperate report. Basically I have a skill matrix spread worksheet I need to extract data from using a keyword search so: the dbase sheet is designed as: Col a Col B through to Col Z Row 1 Skill title i.e. Excel Row 2 Name Knowledge level between 1 to 5 i.e. 2 Note there is about 100 rows of names. example therefore is: Excel word Colin ...

socket
CSocket sock; if(sock.Create(0,SOCK_DGRAM,0) == false) { AfxMessageBox("Create"); return; } UINT portnr = 5000; if (sock.Bind(portnr,"10.0.0.10") == false) { int error = sock.GetLastError(); AfxMessageBox("Bind"); return; } When running this code I get an error 10022. According to msdn.microsoft.com it means : 10022 An invalid argument was supplied. WSAEINVAL What am I doing wrong ? Minor detail: it is silly to write "== false" because it might fool you into thinking that the opposite is "== true", which is not always the c...

Can't send document to a CD in Pack and Go -- says "incorrect func
I am trying to pack and go, send to a commercial printer, etc, -- When I choose the "browse" and then choose the E (CD where I want to copy it) I get a window saying "incorrect function", followed by another window saying I need to contact the administrator as I don't have permission. I am the administrator and I have double checked this and clicked all the buttons (I think) giving me the permissions to do everything and since I am the only administrator this should do the trick -- but it doesn't. Originally this was my husbands computer -- but he is no l...

Sending/Receiving #2
I just installed Microsoft Office Enterprise 2007 on my computer and trying to set up Outlook. When I tested the settings, it said everything was fine. Yet, when I hit send/receive, I get the message, "The Operation Failed. An object could not be found." I don't understand this and tried looking at the microsoft website and find nothing about this. When I tried to send an individual email, it says that it failed because I didn't have enough memory. When I ran a memory diagnostics test, it said everything was fine. I have been running Windows Mail on the computer...

Reassigning accounts changes owenr on ALL objects....
We had a sales guy leave so I reassigned his accounts to various other reps....worked great EXCEPT it reassigned all objects related to that Account....even the completed ones. Where it screws me up the most is on orders already created and the reportinig that I have created....it moves those historical orders to new rep. reports have to be based on order owner vs created by because we have admins that do some order entry. Is there any way to reassign account and NOT have it change the owner on any activity/order/etc that has been completed or is in the past?????? maybe an append query at th...

send e-mail from CRM
What is necessary to send e-mail from MS CRM? I'm new in CRM and I have a lot of problems with this activity. I can't send e-mail from CRM. Should install Exchange Mail Router for CRM or it's necessary only when i installed Sales for Outlook? Btw - (I've installed Router - any warnings, I think that everything is ok) but when I create activity from e-mail in Outlook this e-mail appeared in CRM or not... any ideas? thanks, JP Hi Janusz, You must install the Microsoft CRM-Exchange E-Mail Router to be able to manage e-mails in Microsoft CRM. If you don't, you can ...

Good POP client to download messages to folders as .msgs?
I work for an NASD regulated firm, so we archive 3 years of email. We used to just archive PST files of the mailbox that contained all the outgoing and incoming emails (via journaling). What I want to use now is use some pop3 client that can download messages from Exchange and put them into .msg formats in some folder on my main archiving PC. Much easier to index the stuff. Anyone know of a pop3 client that places files into directories? So each message is its own little text or .msg file? Thanks! Way too convoluted. Go with Enterprise Vault from Symantec to archive and show compl...

CListCtrl Scroll Messages
Does anyone here have example code that show how to send a WM_VSCROLL message to a CListCtrl control using SB_THUMBPOSITION, SB_THUMBTRACK, and SB_ENDSCROLL to scroll a listctrl? I have watched spy++ and can clearly see that these are the messages that are being sent to the CListCtrl when dragging the thumb control of CListCtrl's scrollbar, but I can't get the list to scroll by doing SendMessage commands to the CListCtrl. Can anyone post sample code on how to do this properly if it is possible? Thanks, Greg WORKAROUND : CListCtrl :: EnsureVisible() Complex but effective - owner dr...

REQ: Help! Dynamics COM object gives "Access Denied" from ASP.NET
I am trying to automate some data entry for our admin support team by authoring web-based pages which interact with Great Plains Dynamics. Currently, I am designing a proof of concept which will open the Item Maintenance page (IV_ITEM_MAINTENANCE) and programmatically fill the "Item Number" field, move focus to another field (so Dynamics will fill the Item Description info into the "Item Description" field), and then read the text from the "Item Description" field. I am able to get the code to properly work both in VB6 and VB.NET (as a WinForms Application). Ho...

Outlook stopped sending after...
I have been sending out a large number of E-mails to clients (200), and about half way, it stops sending, and won't send any more. I thought it was the "next" mail item to go, so I deleted it, but the rest act the same. I used Word 2003 MailMerge to generate the Messages, so there are a number of small messages, instead on message out to 200 people. Client: Outlook 2003 Mail Server: Postfix (ISP's) Any help would be appreciated. Thanks. ...

Query Based on Weekdays vs Weekend
Is it possible with a date/time field in the General Date format (mm/dd/yyyy hh:mm:ss) to query based on the Day of the week?? Trying to isolate entries from between Monday - Friday with the General Date format. Any help would be appreciated. Thanks SELECT Field1, Field2, Field3 FROM MyTable WHERE Weekday(MyDateField) IN (2, 3, 4, 5, 6) (Sunday is 1, Monday is 2 and so on up to Saturday is 7) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "JMcMusicman" <JMcMusicman@discussions.microsoft.com> wrote in message news:498FF00F-2B...

thumbnail in field?
I'm making a simple database of my model trains. one of the (form) fields is "Photograph" and it asks me to right click>insert object> and either Create New or Create from File. I've been choosing from file, I select an image and show as icon. the icon goes away after I reopen the form. Is there a way to show a thumbnail of the photo? espee2, You really don't want to store pictures in the database (though Access 2007 does handle images better), it cause bloating which will push your database to it's max size very quickly. Try this link which has MA...

How do you send mail from two mailbox's in one Outlook Profile?
Does anyone know how to configure a user to be able to send mail from two different mailbox's within the same Outlook profile? I have two exchange 2003 servers and some users need the ability to be able to send mail from two different mailbox's. I am aware of the send on behalf feature but I need to be able to send mail from each mailbox is it has to appear is came from the correct domain address .. E.G one mailbox has an address of john@my-company.com on one server and the second mailbox has an address of john@our-company.com on the other server. I need to be able to reply or create...

Multiple value field displaying number instead of what is in the table
I have two columns on my report. One column named Loss Category that is bound by the field Loss Category on my table and is set up as a combo box that allows multiple values to be selected on the form. For example, a user may select fraud or personal injury OR fraud and personal injury. The second column on my report is named Risk Information that has the following expression: RiskInfo: "Loss Date: " & Chr(13) & Chr(10) & [Loss Date] & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Insurance Defense:" & Chr(13) & Chr(10) &a...

Where is the field that holds the total time for a case?
All, I am trying to pull the value for total time from the CRM database for a case. I want the value that shows up in the resolve pop-up as total time (time entered in the activities of a case). Also would like to find the billable time. Have a great day, Barry The method you want is incident.calculatetotaltime which is documented in the SDK. Hope that helps! Graham "Barry" wrote: > All, > I am trying to pull the value for total time from the CRM > database for a case. I want the value that shows up in > the resolve pop-up as total time (time entered in t...

Can we show a custom field on the Event page?
I have a shared calendar to reserve conference rooms. We use the Subject field to show the group/topic that is using the room and the Location field to show which room is reserved for the meeting. But I'm finding that sometimes we need to know who reserved the room. Is there a way to add a field to the Event page under Subject and Location? I know I can add a field to the table/All Events view but I'll never get my users to use that. I'd like to have a field right on the Event page that will be hard for them to ignore. Thanks, Randy -- Smooth seas never made...

Outlook 2003 is not finding recent messages using the find function
One of our client have problems when searching for a message in his inbox. Recent received mails are not found. Only mails who are already a few hours in his inbox are found . The cashing is enabled. On the exchange server the full text indexing is disabled. His inbox contains +/- 20.000 mails In news:OOGMGUZAGHA.3352@TK2MSFTNGP10.phx.gbl, Paul <pcauwe@hotmail.com> typed: > One of our client have problems when searching for a message in his > inbox. Recent received mails are not found. Only mails who are > already a few hours in his inbox are found . The cashing is enabled....

[ANN] Office 12.0.1 Updater Now Available via AutoUpdte
In case there are some who don't have the AutoUpdate set to check automatically, the new 12.0.1 updater is now in place. I just applied it myself & all appears to have gone as expected thus far. All apps About screen reflect the 12.0.1 nomenclature. Regards |:>) Bob Jones [MVP] Office:Mac In article <C401198A.35E35%onlygeneraltaz1@com.cast.net>, CyberTaz <onlygeneraltaz1@com.cast.net> wrote: > In case there are some who don't have the AutoUpdate set to check > automatically, the new 12.0.1 updater is now in place. I just applied it > myself & all ...

this message is being watched?
In an email from a friend, when i open it I receive a message in the greyed out area just below the toolbar. There is a pair of eyeglasses in a yellow line with the message...."This message is being watched" Anybody know what this could mean? Try posting this in an Outlook Express news group - this is not one of them. Outlook is a part of Microsoft Office and is what this group supports. Outlook Express is a part of Internet Explorer and has its own news groups. You can also find some good Outlook Express information here: http://insideoe.tomsterdam.com --� Milly Staples ...

Outlook 2007 XP sending problems
This is the message I get when I try to send an email with Outlook using Windows Live Mail- An unknown error has occurred. Account: 'pop3.live.com', Server: 'smtp.live.com', Protocol: SMTP, Server Response: '500 Unsupported command.', Port: 25, Secure(SSL): Yes, Server Error: 500, Error Number: 0x800CCC62 - does ANYone know what the heck this means??? Im pretty sure it has something to do with my smtp port settings which I assumed were set by default???? Can someone help me with this?? morphy wrote: > This is the message I g...

CDO or Mapi for searching mailbox, sending mail
Hello guys, can you please advise which library is the most current and suitable for my task. I need to search and find mail in my mailbox based on sender and subject criteries, construct 'replay all' mail, edit it, attach files and send it. I see some of it can be done with CDO, all can be done with MAPI. However I am not sure which one should I use. ...

Change autonumber field to number field
Is there a convenient way to change an autonumber field to a number field? I tried using the table design view but received the error: "You can't change the data type or field size of this field; it is part of one or more relationships. If you want to change the data type of this field, first delete its relationships in the Relationships window." If I were to break and remake the relevant relationships, would that suffice or might there be downstream effects which are not rectified when the relationships are remade? Many thanks, Paul Hello Paul. "paulkaye" wrote:...

Replies not showing original message
I use Outlook 2000 and sometimes when I reply to a message the original message does not show when I am responding to it. If I CC myself on the message I see my reply and the original message. I'm so confused. I noticed it happening when I tried to look down in the original message for reference and it wasn't there. But then on other messages everything is there. I have the settings set to show the original message in replies and forwards. Any suggestions? ...