Can't I say
winsock.senddata "data"
doevents
winsock.senddata "another data"
doevents
?
It is sending only first data
second data not sent
why ?
Printable View
Can't I say
winsock.senddata "data"
doevents
winsock.senddata "another data"
doevents
?
It is sending only first data
second data not sent
why ?
I think that the client must use GetData method to retrieve the sent message, before the server can continue.
I know nothing about winsock, but if that is true then you will need to have an acknowledgement message returned before the server sends any more data. If I were to write something that used winsock I would design a message queue where the server adds messages to be sent and the queue sends the next message when the last sent message has been acknowledged...just a suggestion :-)Quote:
Originally Posted by gavio
There could me many problems, it's hard to tell what is the problem if you don't provide any code.Quote:
Originally Posted by ASoufan
Actually, that's not trueQuote:
Originally Posted by gavio
Winsock is streamming... From the first call of SendData it starts to send, sending is slow, so it sends byte by byte until it's done.
Client receives data, and sends a "DataArrival" event whenever the buffer is full (~ 4KBytes), or it reaches a time-out (a few milliseconds). Client returns whatever it has in the buffer at that particular time.
So, for one SendData at server, there could be 10's or even 100'dreds of DataArrivals at client.
For example you have one SendData, and in that call you send 100 KBytes.
It starts sending, after it reaches ~ 4KBytes, the client issues a DataArrival to empty it's buffer, then the same for the next 4K, and so on... until there is no more data in the buffer.
So for 100 KBytes, you will get 25 calls to DataArrival.
But most importantly, you should not assume that the DataArrival will fire at exactly 4K, that's the number I got from my tests, but you should design the program in such a way assuming that the DataArrival could fire at any interval and at any buffer threshold.
So, when you send data, example "some data", send it like this "[START]some data[END]", or anything to mark the beginning of your data, and end of data.
The client will have to look for "[START]" and "[END]" tags, and it will know how to break down the data received.