Re: difficulty with wsockreaddata

new topic     » goto parent     » topic index » view thread      » older message » newer message

Alan,

My solution was to read one byte at a time from the socket within a loop.
If I got a WSA_WOULDBLOCK or a LF, then I knew I'd gotten one whole line.
It is kind of a hack, since there are more efficient ways of doing things,
but it works.  Also, you should make sure you've got the latest version of
the winsock library.  The new version will do asynchronous sockets, which
are a little harder, but work much better because the machine will just
look for data, not wait on it.

I also got started on a mail client a long time ago (actually just a front-
end to a Windows sendmail program).  It has built-in DNS capabilites and
can encode attatchments to BASE64 standards.  When you get that far, let me
know, and we can swap notes.

Brian
-- junk now contains the client's responce up to the first CRLF

On Mon, 20 Mar 2000 20:35:44 -0600, Alan Tu <alantu at STUDENTS.UIUC.EDU>
wrote:

>First, I'd like to express my appreciation to the Winsock team for doing
>much of the dirty work in coding all these API calls.  The following code
>(which I'm having trouble with) is a modified snippet of Greg Harris's
>wsclient.exw in the winsock package.
>
>In general terms, my program has no trouble connecting to my pop server. It
>has no trouble sending and receiving data. Its the parsing that I'm having
>trouble with.
>
>At this point in the code, the program has connected to my server.
>
>errorRtn = WsockSendData(client,"user alantu\n")
>errorRtn = WsockSendData(client,"pass x\n")
>--assuming my password is x
>errorRtn = WsockSendData(client,"stat\n")
>-- The purpose of this program (as a first step)
>-- is to check if there are messages.
>errorRtn = WsockReadData(client,80)
>errorRtn = WsockReadData(client,80)
>errorRtn = WsockReadData(client,17)
>errorRtn = WsockReadData(client,12)
>
>if sequence(errorRtn) then
>    Say(errorRtn,"Winsock Says!")
>end if
>--closes connection
>
>For one particular set of data, the code works by popping up a dialog
saying
>+ok 2 4746!
>
>But of course, I might have 10 messages (one extra digit) or I might have 0
>messages.  If I fiddle with the bytes to read, sometimes the dialog
displays
>nothing (actually, no dialog comes up at all). I looked at the read data
>routine and it seems that there's a while loop and when there's no more to
>read, it exits. So I figured after each input I'd read 80 characters to get
>a max one line. If there were fewer characters, then the sequence would
just
>have that line. I had a read data after each send data and just tried to
>display the last read data, but that didn't work either. I can't think of a
>clean (or even a workable general solution) to this problem. Can someone
>help me? Thanks.
>
>Alan

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu