1. difficulty with wsockreaddata
- Posted by Alan Tu <alantu at STUDENTS.UIUC.EDU> Mar 20, 2000
- 424 views
- Last edited Mar 21, 2000
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
2. Re: difficulty with wsockreaddata
- Posted by Brian Jackson <bjackson at 2FARGON.COM> Mar 21, 2000
- 444 views
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
3. Re: difficulty with wsockreaddata
- Posted by Mike Sabal <MikeS at NOTATIONS.COM> Mar 21, 2000
- 449 views
Are you using sockets or MAPI? I'd like to get some MAPI wrapped, but the = lack of 96-hour days prevents this . >>> bjackson at 2FARGON.COM 03/21/00 10:14AM >>> I also got started on a mail client a long time ago (actually just a = front- end to a Windows sendmail program). =20
4. Re: difficulty with wsockreaddata
- Posted by Brian Jackson <bjackson at 2FARGON.COM> Mar 21, 2000
- 438 views
I'm using WinSock2.2. I had to code all the protocols by hand, but I now speak fluent SMTP There are only 12 MAPI functions in the SimpleMAPI subset, and those could be done in a day. Unfortunately, I'll have no free time until 2007 or so... Any takers? On Tue, 21 Mar 2000 11:32:42 -0500, Mike Sabal <MikeS at NOTATIONS.COM> wrote: >Are you using sockets or MAPI? I'd like to get some MAPI wrapped, but the lack of 96-hour days prevents this . > >>>> bjackson at 2FARGON.COM 03/21/00 10:14AM >>> > >I also got started on a mail client a long time ago (actually just a front- >end to a Windows sendmail program).