Hello
I am writing an application in VB6 that listens for incoming sockets that will send data to my application, and then it will do something with that data.
The data being received is variable in length but always begins with a "header" containing, among other things, the length of the variable part of the packet.
I will be listening for sockets on a control array of 500 Winsock controls. Obviously only one DataArrival event will fire at any one time, but the client will connect multiple sockets and send data on them simultaneously.
What is the best way to ensure data integrity? At the moment, as soon as the DataArrival event fires I am removing the data from that winsock's buffer and appending it to the value in a global variable. This is working OK at the moment but is not desirable as a) one bit of bad data will stuff up the entire string of data in the variable and b) if another DataArrival event fires before the end of the entire data is received on a previous socket, the new data will be inserted into the middle of that packet on the global variable.
What's the best way to deal with a situation like this? I read that .PeekData until the correct length packet is received is poor programming practice.
Also, is there any way to pause until a Winsock control's .State property changes to sckConnected without looping DoEvents statements?
Thanks
Nick
I am writing an application in VB6 that listens for incoming sockets that will send data to my application, and then it will do something with that data.
The data being received is variable in length but always begins with a "header" containing, among other things, the length of the variable part of the packet.
I will be listening for sockets on a control array of 500 Winsock controls. Obviously only one DataArrival event will fire at any one time, but the client will connect multiple sockets and send data on them simultaneously.
What is the best way to ensure data integrity? At the moment, as soon as the DataArrival event fires I am removing the data from that winsock's buffer and appending it to the value in a global variable. This is working OK at the moment but is not desirable as a) one bit of bad data will stuff up the entire string of data in the variable and b) if another DataArrival event fires before the end of the entire data is received on a previous socket, the new data will be inserted into the middle of that packet on the global variable.
What's the best way to deal with a situation like this? I read that .PeekData until the correct length packet is received is poor programming practice.
Also, is there any way to pause until a Winsock control's .State property changes to sckConnected without looping DoEvents statements?
Thanks
Nick