09-12-2011 03:27 PM
The LabView application that I have creates a server coacket and accepts only "string" data. My C# application creates a client socket and tries to send "byte" data over socket. How can I make this work? C# socket function does not allow me to send "string" data. It forces me to convert the data to byte array.
09-13-2011 05:37 PM
vsanghvi,
Im a bit confused with exactly what were doing here. I understand were trying to pass data from a LV application to some C# code, but are we using data sockets? Also, are you using measurement studio for your C# code, and if so what version?
Can you give us a snippet of code from the client and server side to help show us what youre doing?
Regards,
Kyle Mozdzyn
Applications Engineering
National Instruments
09-14-2011 12:02 PM
Hi,
Sorry for the confusion.
LV is creating the server data socket and I'm trying to create client from C# (not using measurement studio). The byte array that I was sending from C# was not being read by LV. I found the issue was with the way I was encoding the string in C#.
C# code:
string strCommand;
byte[] byData = System.Text.Encoding.UTF8.GetBytes(strCommand);
int nBytes = clientSock.Send(byData);
Instead of UTF8 I was trying ASCII and UNICODE, which was not doing the right string to byte conversion. Everything is working fine now.
Thanks
Vane
09-15-2011 10:08 AM
Vane,
Its good to hear you were able to get it up and running!
Regards,
Kyle Mozdzyn
Applications Engineering
National Instruments