winsock control: buffer flushing? 
Author Message
 winsock control: buffer flushing?

We're writing a client/server Internet app in Visual Basic 5, using the
winsock control, and there seem to be times when the send-buffer suddenly
becomes "larger", and packets are not sent immediately (as we would like).
Is it possible to flush the output buffer like you can do with some
commercial ocxes, and if not, can we do it through the winsock API?

Also, as many others have said in this newsgroup, I have a network card and
a dialup connection in the Internet, but the local ip setting in VB seems
only to report my static network card address, not the dynamic address bound
to the dialup adapter. Help would be appreciated - please Email, as my ISP's
newsfeed is not brilliant :-(

Thanks in advance,

Nick



Mon, 22 May 2000 03:00:00 GMT  
 winsock control: buffer flushing?

Quote:
>to the dialup adapter. Help would be appreciated - please Email, as my
ISP's
>newsfeed is not brilliant :-(

Ive got the same kind of problem:

I try to make an SMTP-client. It seems that every SMTP-command has to be
individually accepted by the server. Now when I try the following sequence:

winsock.senddata "Helo mail.own.fi"


etc.

it seems that all the stuff goes to TCP-buffer and it is sent as one packet
instead of three (or more...) separate packets.

So, the question is: How can I force winsock to send data - one line - one
packet? Or is there a way for that?

Thanks in advance,

Aki



Tue, 23 May 2000 03:00:00 GMT  
 winsock control: buffer flushing?


Quote:
>I try to make an SMTP-client. It seems that every SMTP-command has to be
>individually accepted by the server. Now when I try the following sequence:

>winsock.senddata "Helo mail.own.fi"


>etc.

>it seems that all the stuff goes to TCP-buffer and it is sent as one packet
>instead of three (or more...) separate packets.

>So, the question is: How can I force winsock to send data - one line - one
>packet? Or is there a way for that?

This is the way that TCP sockets work.  They are "stream" sockets, which
means that all you can guarantee about transmission is that the packets
will arrive in order.  A single send may be broken up into more
fragments, or several sends may be combined.  It is possible to tell the
socket stack not to hold short packets awaiting further packets, but
doing so is generally not advised, and will usually have the effect of
_reducing_ the transfer speed of your program - not what you want, at
all.

It's important for you to use the other aspects of SMTP that make it
workable over TCP - each command gets a response, so you should send the
command, then wait for the response before sending the next one.  
Otherwise, you may be sending a command that is not allowed, due to the
failure of a previous one.

Note also that you do not show the <CR><LF> sequence being sent - does
your senddata function do this?  If not, you will have to include these
characters in the data sent.

Alun.
~~~~

---
Texas Imperial Software     |   Try WFTPD, the Windows FTP Server.
1602 Harvest Moon Place     |   Available at the web site
Cedar Park TX 78613         |   http://www.wftpd.com

Phone +1 (512) 257 2578     |   Now accepting credit card orders!
===================================================================
***** WFTPD Pro, an NT Service FTP Server supporting multiple *****
** simultaneous virtual hosts, is now available for $80 per copy **



Tue, 23 May 2000 03:00:00 GMT  
 winsock control: buffer flushing?



Quote:
> We're writing a client/server Internet app in Visual Basic 5, using the
> winsock control, and there seem to be times when the send-buffer suddenly
> becomes "larger", and packets are not sent immediately (as we would

like).

Have you perhaps noticed whether the Winsock Control loses the last packet
of information when the server closes the connection?

I wrote a FTP app using the Winsock control and when doing a RETR on a
large file the last packet of information is sometimes lost as the server
closes the connection to signify EOF.

In relation to your problem, try adding a vbCrLf to the end of each command
string you send.

Please let me know if this helps and if you perhaps have a solution to my
predicament.

thanks

Steve


http://home.pix.za/sh/sh000001



Tue, 23 May 2000 03:00:00 GMT  
 winsock control: buffer flushing?

Quote:
>Note also that you do not show the <CR><LF> sequence being sent - does
>your senddata function do this?  If not, you will have to include these
>characters in the data sent.

I forgot to write vbcrlf to the code lines I sent in my previous message,
sorry. Anyway, if I try first to send a line:

winsocket.senddata "Helo mycomputer.fi" & vbcrlf

and then write:

winsocket getdata data
if left(data,3)<>"250" then    ' Test if the server sends 250 ok
    msgbox "Failure"
end if

It seems that the "Helo"-command leaves my computer but the servers response
never gets to winsock. (But the server responses, since I see it from the
Network Monitor). So, the test failures and I cant continue.

Then if I write several senddata -lines my computer send them all at one
packet and the server understands only the first line eg. "Helo....".

So:

Quote:
>fragments, or several sends may be combined.  It is possible to tell the
>socket stack not to hold short packets awaiting further packets, but

How is this possible?

And a question further: Is there any good resources available on programming
winsocket with VB?

Thanks for helping me,

Aki



Wed, 24 May 2000 03:00:00 GMT  
 winsock control: buffer flushing?

Quote:
>I forgot to write vbcrlf to the code lines I sent in my previous message,
>sorry. Anyway, if I try first to send a line:

>winsocket.senddata "Helo mycomputer.fi" & vbcrlf

>and then write:

>winsocket getdata data
>if left(data,3)<>"250" then    ' Test if the server sends 250 ok
>    msgbox "Failure"
>end if

>It seems that the "Helo"-command leaves my computer but the servers
response
>never gets to winsock. (But the server responses, since I see it from the
>Network Monitor). So, the test failures and I cant continue.

>Then if I write several senddata -lines my computer send them all at one
>packet and the server understands only the first line eg. "Helo....".

Where/when do you make the GetData call?

If you are not doing it "after" the DataArrival event fires, then you
are "not" going to get what you expect. Why? ... Network delays,
slow mail server due to many connections, the list goes on ... simply
put, you have not given the server enough time to reply.

What I'm getting at is that you need to do your code in a State Table
format. This is where most people loose it when it comes to doing
SMTP/POP3. Unless one does their coding in a State Table format,
you will never have a reliable app unless you use a 3rd party control
(and if you look at it's code, yep, State Tables).

Quote:
>And a question further: Is there any good resources available on
programming
>winsocket with VB?

Ya need to get into the mind set of doing things in state tables if you
want to do internet apps as this applies to ftp, www, etc.

For me, it was about 6 years back when I was just starting to do rs232
coding,
and old timer told me I would never "get it right" unless I learned how to
code
via state tables. I did not know how then and asked him to show me and this
is where I picked it up. I'm not sure what book to point you at.

Marvin



Fri, 26 May 2000 03:00:00 GMT  
 winsock control: buffer flushing?

Another thing to keep in mind with SMTP is that, when you start
actually sending the text/body of your message, you will not receive
a reply back until you terminate the body of the message with a
<CRLF>.<CRLF>



Sat, 03 Jun 2000 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. winsock control: buffer flushing?

2. Solution: Winsock Does Not Flush Buffer Correctly

3. Flushing buffer?

4. Qbasic- Flushing the buffer

5. Buffer Flush

6. serial port buffer flushing ?

7. Flushing keyboard buffer

8. Q: How to Flush VB File buffers

9. Need to flush keyboard buffer somehow

10. SendKeys for Dos and Buffer flushing

11. flush keyboard buffer?

12. Flush File Buffers API

 

 
Powered by phpBB® Forum Software