How can i sent structures through SOCKETS
-
Hi,i am trying to sent structures through SOCKETS,but the information is not reaching the server. I need source code to sent structures and delimit at server side
-
Hi,i am trying to sent structures through SOCKETS,but the information is not reaching the server. I need source code to sent structures and delimit at server side
Hope you would be sending commands in those structures. you can do like this. send this to client. struct SomeData { int command; int param1[100]; int param2[100]; } on client side read the sizeof(int) to get the command type the structure contains. once you know the command , you should read the 100 bytes for first param and then 100 for another param. This way your structure will be transmitted across wire. Hope this helps.
Z.A
-
Hi,i am trying to sent structures through SOCKETS,but the information is not reaching the server. I need source code to sent structures and delimit at server side
Ca nyou post the code for the transmit receive that you have already ? I never worked with socket before but I suppose it works like any other 'communication' media. So for example if you are trying to pass the address of your structure, it will only transmit the address and not the content. Can you post your code to clarify the situation ?
Cédric Moonen Software developer
Charting control [Updated - v1.1] -
Hope you would be sending commands in those structures. you can do like this. send this to client. struct SomeData { int command; int param1[100]; int param2[100]; } on client side read the sizeof(int) to get the command type the structure contains. once you know the command , you should read the 100 bytes for first param and then 100 for another param. This way your structure will be transmitted across wire. Hope this helps.
Z.A
Thankq Mr. zubair_ahmed, But i want 2 give clear idea abt the problem which i got. This is the data which i want 2 send: struct data { int id; CString str1; CString str2; }pt; UpdateData(); CString str; pt.str1=m_ID; pt.str2=m_Name; pt.id="A"; str.Format ("%d#%s#%s",pt); send(clientsock,str,str.GetLength(),0); Here Iam sending structure data tru string but.. is there any way to send data by structure address?? and How to get back the data at server side ...Thanks swamy
-
Thankq Mr. zubair_ahmed, But i want 2 give clear idea abt the problem which i got. This is the data which i want 2 send: struct data { int id; CString str1; CString str2; }pt; UpdateData(); CString str; pt.str1=m_ID; pt.str2=m_Name; pt.id="A"; str.Format ("%d#%s#%s",pt); send(clientsock,str,str.GetLength(),0); Here Iam sending structure data tru string but.. is there any way to send data by structure address?? and How to get back the data at server side ...Thanks swamy
-
Thankq Mr. zubair_ahmed, But i want 2 give clear idea abt the problem which i got. This is the data which i want 2 send: struct data { int id; CString str1; CString str2; }pt; UpdateData(); CString str; pt.str1=m_ID; pt.str2=m_Name; pt.id="A"; str.Format ("%d#%s#%s",pt); send(clientsock,str,str.GetLength(),0); Here Iam sending structure data tru string but.. is there any way to send data by structure address?? and How to get back the data at server side ...Thanks swamy
Hello Narasimha,
swamy Narasimha wrote:
is there any way to send data by structure address?
I think u have both client server on same PC. And u want to do Inter Process communication via socket. Isn't it?
regards, Divyang Mithaiwala System Engineer & Software Engineer
-
Hello Narasimha,
swamy Narasimha wrote:
is there any way to send data by structure address?
I think u have both client server on same PC. And u want to do Inter Process communication via socket. Isn't it?
regards, Divyang Mithaiwala System Engineer & Software Engineer
hi Divyang Mithaiwala, Iam sending data from one sys to another sys (two seperate systems) with IP and port.
-
hi Divyang Mithaiwala, Iam sending data from one sys to another sys (two seperate systems) with IP and port.
Hello swamy Narasimha, For that u have to type cast ur struct pointer to char pointer. But it is quit risky. Becoz as u know that differeint platform use different size for int datatype. And also change possion for date in struct to optimize best space. In both of this case ur data at other end is useless. And that's why some COM component provide fisrt field as sizeofstruct. To conform that both end use same style for data arrangment.
regards, Divyang Mithaiwala System Engineer & Software Engineer