Results 1 to 4 of 4

Thread: WinSock Problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    138

    WinSock Problem

    Can't I say
    winsock.senddata "data"
    doevents
    winsock.senddata "another data"
    doevents
    ?

    It is sending only first data
    second data not sent
    why ?

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: WinSock Problem

    I think that the client must use GetData method to retrieve the sent message, before the server can continue.

  3. #3
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: WinSock Problem

    Quote Originally Posted by gavio
    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 :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  4. #4
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: WinSock Problem

    Quote Originally Posted by ASoufan
    Can't I say
    winsock.senddata "data"
    doevents
    winsock.senddata "another data"
    doevents
    ?

    It is sending only first data
    second data not sent
    why ?
    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 gavio
    I think that the client must use GetData method to retrieve the sent message, before the server can continue.
    Actually, that's not true

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width