Hi all,
I have a problem. I am writing a client server app in C. In my client
program, I have a simlple struct similiar to:
struct mySt{
int id;
char val;
struct mySt *next;
};
I want to be able to fill out the variables in this struct and then
send it to the server.
I do this using:
struct mySt pStruct;
pStruct.id = 1;
pStruct.val = 'a';
send ( sd, &pStruct, sizeof(struct pStruct), 0);
on the server though, even though I do receive this info. I have no
idea how to parse. I recieve a data in a variable of the same type
(struct mySt), but I don't know how to read it / parse it. Is it read
into char or can I do something like:
struct mySt **receivedPacket;
int id = receivedPacket[0];
Thanks 2 4552
Jack wrote:
Hi all,
I have a problem. I am writing a client server app in C. In my client
program, I have a simlple struct similiar to:
Please don't multi-post on Usenet, cross-post if you must, but don't
multi-post. You also asked this on comp.unix.programmer, which is
probably where it should be answered.
--
Ian Collins.
Jack wrote:
Hi all,
I have a problem. I am writing a client server app in C. In my client
program, I have a simlple struct similiar to:
struct mySt{
int id;
char val;
struct mySt *next;
};
Sending raw struct's over the wire is a really bad idea, even between
homogeneous systems.
Depending on the compiler used, different padding may be used.
So don't do that... for more advanced protocols ASN.1 is typically used,
but for simpler applications, you can just define endian order of
binary data, and pass each struct member along the wire.
--
Tor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Leo |
last post by:
Hello,
I have a C dll with a method signature of:
int activate(datastruct *data)
where datastruct is defined as:
typedef struct datastruct {
long result;
|
by: Fernando Barsoba |
last post by:
Dear all,
I have been posting about a problem trying to encrypt certain data using
HMAC-SHA1 functions. I posted that my problem was solved, but
unfortunately, I was being overly optimistic. I...
|
by: Abubakar |
last post by:
Hi,
I am writing a server in C# and client in C++ (pure, not managed). The
communication goes on through sockets. In C# I am using NetworkStream to
send text data (by converting it to byte array)...
|
by: thorley |
last post by:
Greetings, since there was no reponse to my previous post about an
existing FastCGI server in python, I've taken to writing my own. (which
of course I'll share--*if* there's something to share ;)
...
|
by: simu |
last post by:
I've a problem with sending a structure of the type pkt over my
connected socket. I've not too much experience in programming C/C++.
Thus, I've no clue what the problem could be. I've spent quite a...
|
by: Sean |
last post by:
Hi guys,
I have a question. I am trying to write a simple echo program. The
objective is to read in a file in chuncks into the buffer and transfer
the buffer over the socket. We repeat this until...
|
by: Thomas Dybdahl Ahle |
last post by:
Hi, I've writing a python application in which I'd like to have a small
"ping label", to always tell the current ping time to the server.
It seems however that I have to be root to send those...
|
by: Jack |
last post by:
Hi, All,
is it possible to send a struct using the the send function. Here is
what I mean
typedef struct{
int ID;
char name;
}sampleStruct;
int main(){
|
by: =?Utf-8?B?RWl0YW4=?= |
last post by:
Hello,
I need to send a "struct" to an embeded CPU over the Ethernet.
The struct is defined like this:
public struct MyStruct
{
public double dVar1;
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
| |