LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   problem in sending array of structures in client/server program (https://www.linuxquestions.org/questions/programming-9/problem-in-sending-array-of-structures-in-client-server-program-520496/)

soumya_b 01-18-2007 08:17 AM

problem in sending array of structures in client/server program
 
i am writing a client server program wherein i have to send multiple records containing many fields. when i send from client to server only 1st record is being print not the second. wat can i do in this case?

KenJennings 01-18-2007 08:26 AM

How are you sending the records? Describe how you're writing the data to the socket connection.

MOS JEFF-INITELY 01-18-2007 09:10 AM

send them as a struct.. im assuming your using C

soumya_b 01-20-2007 01:25 AM

i am sending records in a structure.... there r fields defined in the structure... one structure is being sent but not the second and the rest...

KenJennings 01-20-2007 08:14 AM

You're doing a direct write/send of the memory block of the structure? That is bad form for network communications. This is not portable and only works when the client/sender and server/receiver are running on identical architectures.

For better portability between systems a simple thing to do is marshal all your structure elements into a text string. Delimiters between fields help with parsing, and some kind of start/end sentinel values will help the code know when it has received a complete string.

varun_shrivastava 01-21-2007 03:53 AM

r u using IPC or socket programming


All times are GMT -5. The time now is 04:33 PM.